Home rooms are created for all users with role if can_create_rooms is enabled (#1694)

This commit is contained in:
Ahmad Farhat
2020-05-28 14:48:18 -04:00
committed by GitHub
parent 5e4fe3b306
commit fe363e742b
3 changed files with 35 additions and 5 deletions

View File

@ -198,6 +198,11 @@ class User < ApplicationRecord
User.includes(:role).where.not(roles: { name: role })
end
def create_home_room
room = Room.create!(owner: self, name: I18n.t("home_room"))
update_attributes(main_room: room)
end
private
# Destory a users rooms when they are removed.
@ -227,11 +232,6 @@ class User < ApplicationRecord
end
end
def create_home_room
room = Room.create!(owner: self, name: I18n.t("home_room"))
update_attributes(main_room: room)
end
def role_provider
Rails.configuration.loadbalanced_configuration ? provider : "greenlight"
end