Skip to content

Instantly share code, notes, and snippets.

@talum
Created June 2, 2018 01:20
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/b0bac571b01459b653a17ed619f2af35 to your computer and use it in GitHub Desktop.
Save talum/b0bac571b01459b653a17ed619f2af35 to your computer and use it in GitHub Desktop.
module Assignments
# This code lives in a module that we use to namespace our application as part of domain-driven design. You might call this an aggregate root.
def self.update_assignment(assignment_id, title:, description:, collaborator_ids:, assignee_ids:, tasks:, due_in:, due_in_units:)
assignment = Assignment
.includes(tasks: :rubric_items)
.find(assignment_id)
assignment.update(
title: title,
description: description,
due_in: due_in,
due_in_units: due_in_units
)
assignment.set_tasks_from_list(tasks)
assignment.set_collaborators_from_list(collaborator_ids)
assignment.assign(assignee_ids)
assignment.save
PublishableAssignmentValidation.new(assignment).validate
AssignmentManagementView.render_assignment_details(assignment)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment