fix: handle user activation email errors
- Wrap the activation email sending in a begin-rescue block - Log error messages if sending fails - Provide user feedback with an error message and render the new user form again This change improves the user experience by handling potential errors during the user activation email process. If an error occurs, it logs the issue and informs the user to try again, preventing confusion and enhancing the robustness of the registration flow.
This commit is contained in:
parent
a3f6c9770f
commit
812073b148
@ -28,9 +28,15 @@ class UsersController < ApplicationController
|
||||
# flash[:success] = "Welcome to the Sample App!"
|
||||
# redirect_to @user
|
||||
# redirect_to user_url(@user)
|
||||
begin
|
||||
@user.send_activation_email
|
||||
flash[:info] = "Please check your email to activate your account."
|
||||
redirect_to root_url
|
||||
rescue => e
|
||||
logger.error "User creation failed: #{e.message}"
|
||||
flash[:error] = "Something went wrong. Please try again."
|
||||
render "new", status: :unprocessable_entity
|
||||
end
|
||||
else
|
||||
render "new", status: :unprocessable_entity
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user