I would like to achieve something as follows where PersonSubject
has many topics, but the choices of these topics are limited to the the selection of topics
through another model (ie: through the associated subject
):
class Topic < ApplicationRecord
belongs_to :subject
end
class Subject < ApplicationRecord
has_many :topics
end
class PersonSubject < ApplicationRecord
belongs_to :person
belongs_to :subject
has_many :topics # where the choices are limited to the subject.skills
end
I would then like if any person_subject.subject.topics
are deleted (or association removed), it would automatically update the person_subject.topics
to no longer "point" to the Topic
(s) that were deleted.
Is this possible?