Last active
December 28, 2015 13:09
-
-
Save patrickdet/7506112 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 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 |
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 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