Skip to content

Instantly share code, notes, and snippets.

@patrickdet
Last active Dec 28, 2015
Embed
What would you like to do?
class UserSignup
def initialize(params)
@params = params
@success = false
signup
end
def user
@user
end
def success?
@success
end
private
def signup
@user = User.new @params[:user]
if @user.save
@success = true
# This is where you start everything once a user has been
# successfully signup.
# 1. send signup email
# 2. run callbacks
# 3. run background processes
else
# do nothing
end
end
end
class UsersController < ApplicationController
def create
user_signup = UserSignup.new(params)
if user_signup.success?
redirect_to user_signup.user
else
render 'new'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment