created models for chatroom

This commit is contained in:
Beatrice Olivera
2018-08-29 13:44:10 +01:00
parent 82079d71cd
commit 085e402c4d
12 changed files with 100 additions and 1 deletions

5
app/models/chat_room.rb Normal file
View File

@@ -0,0 +1,5 @@
class ChatRoom < ApplicationRecord
has_many :users, through: :chat_room_participations
has_many :chat_room_participations
has_many :requests
end

View File

@@ -0,0 +1,4 @@
class ChatRoomParticipation < ApplicationRecord
belongs_to :user
belongs_to :chat_room
end

4
app/models/request.rb Normal file
View File

@@ -0,0 +1,4 @@
class Request < ApplicationRecord
belongs_to :user
belongs_to :chat_room
end

View File

@@ -5,6 +5,9 @@ class User < ApplicationRecord
:recoverable, :rememberable, :validatable
has_many :connections
has_many :chat_rooms, through: :chat_room_participations
has_many :chat_room_participations
has_many :requests
def contacts
self.connections.map do |connection|