I've been using AR_Mailer for about 6 months without ever running into problems. I recently added DelayedJob for some administrative background jobs. Since DelayedJob also handles emails very well (thanks to DelayedMailer gem) I completely removed AR_Mailer from my application.
Everything works perfectly except this email. The password that is generated automatically is now lost.
#app/models/notifier.rb
def activation_instructions(user)
from default_email
@bcc = BACK_UP
@subject = "Activation instructions"
recipients user.email
sent_on Time.now
body :root_url => root_url, :user => user
end
#app/views/notifier/activation_instructions.erb
Thanks for signing up.
Your password is <%[email protected]%>. For security reasons please change this on your first connection.
[....]
Any idea on why this bug occurs? Thanks!
Configuration: Rails 2.3.2 & DelayedJob 2.0.4
I found out where the problem was. I looked in the database at the entry created in the delayed_jobs table:
The
user
parameter is reloaded from the database by delayed_job before sending the email. In that case, the password is lost because it's not stored in the database.So I've updated the code in order to pass explicitly the password:
Hope this helps other too!