summaryrefslogtreecommitdiff
path: root/users/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'users/app/models')
-rw-r--r--users/app/models/user_message.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/users/app/models/user_message.rb b/users/app/models/user_message.rb
index 0b2ce17..37aae0b 100644
--- a/users/app/models/user_message.rb
+++ b/users/app/models/user_message.rb
@@ -7,6 +7,8 @@ class UserMessage < CouchRest::Model::Base
validates :user_id, presence: true
validates :message_id, presence: true
+ # should not have multiple rows connecting one user to particular message:
+ validates_uniqueness_of :user_id, :scope => [:message_id]
property :seen, TrueClass, :default => false
@@ -14,6 +16,7 @@ class UserMessage < CouchRest::Model::Base
view :by_user_id
view :by_message_id
view :by_user_id_and_seen
+ view :by_user_id_and_message_id
own_path = Pathname.new(File.dirname(__FILE__))
load_views(own_path.join('..', 'designs', 'user_message'))