Skip to content

Instantly share code, notes, and snippets.

@thomasguillory
Last active December 30, 2015 13:59
Show Gist options
  • Save thomasguillory/7839676 to your computer and use it in GitHub Desktop.
Save thomasguillory/7839676 to your computer and use it in GitHub Desktop.
class RegistrationService
def self.register attributes
user = User.create attributes[:user]
success = user && user.errors.empty?
{
user: user,
success: success
}
end
# def self.unregister attributes
# ...
# end
end
class RegistrationsController < BaseController
def new
@registration = {}
@registration[:user] = User.new
end
def create
@registration = RegistrationService.register params[:registration]
if @registration[:success]
redirect_to registrations_path, success: "Hoorraa"
else
render action: :new
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment