mirror of
https://github.com/beatriceo/polyglot.git
synced 2025-10-25 10:42:11 +00:00
Merge branch 'master' into page
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 :chat_room_participations
|
||||
has_many :users, through: :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
|
||||
@@ -8,7 +8,7 @@ class Connection < ApplicationRecord
|
||||
|
||||
def create_inverted_connection
|
||||
unless Connection.where('user_id = ? and contact_id = ?', self.contact.id, self.user.id).length > 0
|
||||
Connection.create!(user: self.contact, contact: self.user)
|
||||
inverted = Connection.create!(user: self.contact, contact: self.user)
|
||||
end
|
||||
end
|
||||
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
|
||||
@@ -6,6 +6,9 @@ class User < ApplicationRecord
|
||||
:recoverable, :rememberable, :validatable
|
||||
|
||||
has_many :connections
|
||||
has_many :chat_room_participations
|
||||
has_many :chat_rooms, through: :chat_room_participations
|
||||
has_many :requests
|
||||
|
||||
mount_uploader :photo, PhotoUploader
|
||||
|
||||
|
||||
Reference in New Issue
Block a user