mirror of
https://github.com/beatriceo/polyglot.git
synced 2025-10-25 10:42:11 +00:00
created models for chatroom
This commit is contained in:
5
app/models/chat_room.rb
Normal file
5
app/models/chat_room.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class ChatRoom < ApplicationRecord
|
||||
has_many :users, through: :chat_room_participations
|
||||
has_many :chat_room_participations
|
||||
has_many :requests
|
||||
end
|
||||
4
app/models/chat_room_participation.rb
Normal file
4
app/models/chat_room_participation.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class ChatRoomParticipation < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :chat_room
|
||||
end
|
||||
4
app/models/request.rb
Normal file
4
app/models/request.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class Request < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :chat_room
|
||||
end
|
||||
@@ -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|
|
||||
|
||||
Reference in New Issue
Block a user