summaryrefslogtreecommitdiff
path: root/app/models/chat_name.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/chat_name.rb')
-rw-r--r--app/models/chat_name.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/chat_name.rb b/app/models/chat_name.rb
new file mode 100644
index 00000000000..f321db75eeb
--- /dev/null
+++ b/app/models/chat_name.rb
@@ -0,0 +1,12 @@
+class ChatName < ActiveRecord::Base
+ belongs_to :service
+ belongs_to :user
+
+ validates :user, presence: true
+ validates :service, presence: true
+ validates :team_id, presence: true
+ validates :chat_id, presence: true
+
+ validates :user_id, uniqueness: { scope: [:service_id] }
+ validates :chat_id, uniqueness: { scope: [:service_id, :team_id] }
+end