将电子邮件发送从 AR_Mailer 切换到 DelayedJob 后丢失值
我已经使用 AR_Mailer 大约 6 个月了,从未遇到过任何问题。我最近为一些管理后台作业添加了 DelayedJob。由于 DelayedJob 也可以很好地处理电子邮件(感谢 DelayedMailer gem),因此我从应用程序中完全删除了 AR_Mailer。
除了这封电子邮件之外,一切都很顺利。自动生成的密码现已丢失。
#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.
[....]
知道为什么会出现这个错误吗? 谢谢!
配置:Rails 2.3.2 &延迟作业 2.0.4
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现问题出在哪里了。我在数据库中查看了在elasted_jobs表中创建的条目:
在发送电子邮件之前,delayed_job从数据库重新加载
user
参数。在这种情况下,密码会丢失,因为它没有存储在数据库中。因此,我更新了代码以便显式传递密码:
希望这对其他人也有帮助!
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!