Last active
December 30, 2015 13:59
-
-
Save thomasguillory/7839676 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 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 | |
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 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