Skip to content

Commit

Permalink
moved 2 methods from controllers to interactors
Browse files Browse the repository at this point in the history
user_confirmation_controller#email_activate and
users_controller#UserMailer…. can both be placed in our Interactors
after the unless statement.
  • Loading branch information
npauzenga committed Nov 7, 2015
1 parent 1ed9fd9 commit 3af23b8
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 2 deletions.
1 change: 0 additions & 1 deletion app/controllers/user_confirmation_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ def update
confirmed = ConfirmUserEmail.call(id: params[:id])

if confirmed.success?
confirmed.user.email_activate
flash[:success] = "Welcome to Blocitoff!"
else
flash[:error] = "Sorry, user does not exist"
Expand Down
1 change: 0 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def create
result = CreateUser.call(user_params: user_params)

if result.success?
UserMailer.registration_confirmation(result.user).deliver_now
flash[:notice] = "Thanks! Please check your email to complete sign up"
redirect_to sign_in_path
else
Expand Down
1 change: 1 addition & 0 deletions app/interactors/confirm_user_email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ class ConfirmUserEmail
def call
context.user = User.find_by_confirm_token(context.id)
context.fail! unless context.user
context.user.email_activate
end
end
1 change: 1 addition & 0 deletions app/interactors/create_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ class CreateUser
def call
context.user = User.new(context.user_params)
context.fail!(errors: context.user.errors) unless context.user.save
UserMailer.registration_confirmation(context.user).deliver_now
end
end

0 comments on commit 3af23b8

Please sign in to comment.