Skip to content

Commit a041864

Browse files
committed
Remove job extraction
1 parent 3e09371 commit a041864

File tree

3 files changed

+21
-26
lines changed

3 files changed

+21
-26
lines changed

app/controllers/users/newsletter_subscriptions_controller.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ def create
3939
end
4040

4141
if @user.previously_new_record?
42-
NewUserNotificationJob.perform_later(@user)
43-
elsif @user.needs_confirmation?
42+
NewUserNotifier.deliver_to(AdminUser.all, user: @user)
43+
end
44+
45+
if @user.needs_confirmation?
4446
EmailConfirmationNotifier.deliver_to(@user)
4547
end
4648

app/controllers/users/registrations_controller.rb

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,46 @@ class Users::RegistrationsController < ApplicationController
88
before_action :authenticate_user!, only: [:edit, :update, :destroy]
99

1010
def new
11-
@user = User.new
12-
render Users::Registrations::NewView.new(user: @user)
11+
user = User.new
12+
render Users::Registrations::NewView.new(user: user)
1313
end
1414

1515
def create
1616
create_user_params = params.require(:user).permit(:email, :password, :password_confirmation)
17-
@user = User.new(create_user_params)
18-
if @user.save
19-
NewUserNotificationJob.perform_later(@user)
17+
user = User.new(create_user_params)
18+
if user.save
19+
NewUserNotifier.deliver_to(AdminUser.all, user: user)
20+
EmailConfirmationNotifier.deliver_to(user)
21+
2022
redirect_to thanks_users_registration_path, notice: "Welcome to Joy of Rails! Please check your email for confirmation instructions"
2123
else
22-
render Users::Registrations::NewView.new(user: @user), status: :unprocessable_entity
24+
render Users::Registrations::NewView.new(user: user), status: :unprocessable_entity
2325
end
2426
end
2527

2628
def edit
27-
@user = current_user
28-
@user.email_exchanges.build
29+
user = current_user
30+
user.email_exchanges.build
2931

30-
render Users::Registrations::EditView.new(user: @user)
32+
render Users::Registrations::EditView.new(user: user)
3133
end
3234

3335
def update
3436
update_user_params = params.require(:user).permit(:password_challenge, :password, :password_confirmation, email_exchanges_attributes: [:email])
3537

36-
@user = current_user
38+
user = current_user
3739

38-
if !@user.authenticate(params[:user][:password_challenge])
40+
if !user.authenticate(params[:user][:password_challenge])
3941
flash.now[:error] = "Incorrect password"
40-
return render Users::Registrations::EditView.new(user: @user), status: :unprocessable_entity
42+
return render Users::Registrations::EditView.new(user: user), status: :unprocessable_entity
4143
end
4244

43-
if !@user.update(update_user_params)
44-
return render Users::Registrations::EditView.new(user: @user), status: :unprocessable_entity
45+
if !user.update(update_user_params)
46+
return render Users::Registrations::EditView.new(user: user), status: :unprocessable_entity
4547
end
4648

4749
if update_user_params[:email_exchanges_attributes].present?
48-
EmailConfirmationNotifier.deliver_to(@user)
50+
EmailConfirmationNotifier.deliver_to(user)
4951
redirect_to users_dashboard_path, notice: "Check your email for confirmation instructions"
5052
else
5153
redirect_to users_dashboard_path, notice: "Account updated"

app/jobs/new_user_notification_job.rb

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)