Skip to content
Snippets Groups Projects
Commit 4f912883 authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

add function to update subjects in learning objects put

parent 2067c83e
No related branches found
No related tags found
No related merge requests found
......@@ -45,4 +45,11 @@ module Subjectable
SubjectRelation.where(subject: subject, subjectable: self).destroy_all
end
end
def update_subjects(ids: [])
subjectable = self
old_ids = subjectable.subjects.map { |su| su.id }
add_subjects(ids: ids - old_ids)
remove_subjects(ids: old_ids - ids)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment