Check polymorphic type in validations
* Previously, some models had "duplicated" `belongs_to` associations, which were now removed (and replaced by the `include Creation`).
This commit is contained in:

committed by
Sebastian Serth

parent
be4f2b790d
commit
977fa4539e
@ -1,13 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class StudyGroupMembership < ApplicationRecord
|
||||
ROLES = %w[learner teacher].freeze
|
||||
|
||||
belongs_to :user, polymorphic: true
|
||||
include Creation
|
||||
belongs_to :study_group
|
||||
|
||||
before_save :destroy_if_empty_study_group_or_user
|
||||
|
||||
ROLES = %w[learner teacher].freeze
|
||||
|
||||
def destroy_if_empty_study_group_or_user
|
||||
destroy if study_group.blank? || user.blank?
|
||||
end
|
||||
|
Reference in New Issue
Block a user