diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-02-25 00:17:01 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-02-25 00:17:01 +0100 |
commit | 71fe24096c612996cb2a827c919a4c88ae1e3495 (patch) | |
tree | fb1deed15866b83f0ed1583c91bc4d6fcb432827 /app/models | |
parent | 42eeecba3f334227c10533a065e238f51f6dee4c (diff) |
Adding a Mention model, test stubs
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/mention.rb | 7 | ||||
-rw-r--r-- | app/models/status.rb | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/app/models/mention.rb b/app/models/mention.rb new file mode 100644 index 000000000..52f40e4b2 --- /dev/null +++ b/app/models/mention.rb @@ -0,0 +1,7 @@ +class Mention < ActiveRecord::Base + belongs_to :account, inverse_of: :mentions + belongs_to :status, inverse_of: :mentions + + validates :account, :status, presence: true + validates :account, uniqueness: { scope: :status } +end diff --git a/app/models/status.rb b/app/models/status.rb index 80719140e..d95870393 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -9,6 +9,7 @@ class Status < ActiveRecord::Base has_many :favourites, inverse_of: :status, dependent: :destroy has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status' has_many :replies, foreign_key: 'in_reply_to_id', class_name: 'Status' + has_many :mentioned_accounts, class_name: 'Mention', dependent: :destroy validates :account, presence: true validates :uri, uniqueness: true, unless: 'local?' |