Allow internal user to be part of an study group
This commit is contained in:
@ -2,13 +2,15 @@
|
||||
|
||||
class StudyGroup < ApplicationRecord
|
||||
has_many :study_group_memberships, dependent: :destroy
|
||||
# Use `ExternalUser` as `source_type` for now.
|
||||
# Using `User` will lead ActiveRecord to access the inexistent table `users`.
|
||||
# Issue created: https://github.com/rails/rails/issues/34531
|
||||
has_many :users, through: :study_group_memberships, source_type: 'ExternalUser'
|
||||
has_many :external_users, through: :study_group_memberships, source_type: 'ExternalUser', source: :user
|
||||
has_many :internal_users, through: :study_group_memberships, source_type: 'InternalUser', source: :user
|
||||
has_many :submissions, dependent: :nullify
|
||||
belongs_to :consumer
|
||||
|
||||
def users
|
||||
external_users + internal_users
|
||||
end
|
||||
|
||||
def to_s
|
||||
if name.blank?
|
||||
"StudyGroup " + id.to_s
|
||||
|
Reference in New Issue
Block a user