public
Created

removing conditional and working with provided callbacks

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.