From f1f5e37d7b22a2a7901d003b418d9e06768b49e4 Mon Sep 17 00:00:00 2001 From: songtianlun Date: Wed, 8 Jan 2025 18:00:25 +0800 Subject: [PATCH] fix: improve email activation error handling - Add logging for successful email delivery - Implement error handling for email sending failures - Raise exceptions for further handling This change improves the robustness of the email activation process by logging outcomes and handling potential errors, allowing for better debugging and monitoring of email notifications. --- app/models/user.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 591b6e4..c5a1d3c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -64,7 +64,14 @@ class User < ApplicationRecord end def send_activation_email - UserMailer.account_activation(self).deliver_now + begin + result = UserMailer.account_activation(self).deliver_now + Rails.logger.info "Email sent successfully: #{result.inspect}" + rescue => e + Rails.logger.error "Failed to send email: #{e.message}" + Rails.logger.error e.backtrace.join("\n") + raise + end end def create_reset_digest