Created
June 2, 2018 01:21
-
-
Save talum/0a77f688435b847b2bd43f1a76596ec1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Assignment < ActiveRecord:Base | |
# code omitted | |
def set_tasks_from_list(task_attributes) | |
self.tasks = self.tasks.new(task_attributes) | |
end | |
def set_collaborators_from_list(collaborator_ids) | |
collaborators = collaborator_ids.map { |id| { collaborator_id: id } } | |
self.collaborations = self.collaborations.new(collaborators) | |
end | |
def assign(assignee_ids) | |
assignees = assignee_ids.map { |id| { assignee_id: id } } | |
self.assigned_works = self.assigned_works.new(assignees) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment