Merge branch 'master' into page

This commit is contained in:
Beatrice Olivera
2018-08-30 20:09:00 +01:00
committed by GitHub
33 changed files with 448 additions and 24 deletions

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

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

View File

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

View File

@@ -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
View File

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

View File

@@ -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