Skip to content

Instantly share code, notes, and snippets.

@jontonsoup
Created November 25, 2014 18:08
Show Gist options
  • Save jontonsoup/fe7e0b0c8db3e5cd20e9 to your computer and use it in GitHub Desktop.
Save jontonsoup/fe7e0b0c8db3e5cd20e9 to your computer and use it in GitHub Desktop.
EnrollmentsController
class EnrollmentsController < ApplicationController
def create
enrollment_creator = EnrollmentCreator.new(enrollment_params)
success = enrollment_creator.save
authorize enrollment_creator.enrollment
redirect_to programs_url
end
private
def enrollment_params
{ program: program, learner: current_user }
end
def program
@program ||= Program.find(params[:program_id])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment