Skip to content

Instantly share code, notes, and snippets.

@talum
Created June 2, 2018 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talum/0a77f688435b847b2bd43f1a76596ec1 to your computer and use it in GitHub Desktop.
Save talum/0a77f688435b847b2bd43f1a76596ec1 to your computer and use it in GitHub Desktop.
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