Skip to content

Instantly share code, notes, and snippets.

@lucashungaro
Created September 25, 2012 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lucashungaro/3784008 to your computer and use it in GitHub Desktop.
Save lucashungaro/3784008 to your computer and use it in GitHub Desktop.
removing conditional and working with provided callbacks
class UserController < ApplicationController
def create
@user_creation = UserCreation.new(self)
@user_creation.on_success { redirect_to users_path }
@user_creation.on_failure { render :new }
@user_creation.please_create_an_user_as_admin(params[:user])
end
end
# This could be provided through a block, adding a bit of syntactic sugar:
@user_creation = UserCreation.new(self) do
on_success { redirect_to users_path }
on_failure { render :new }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment