0

私は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 <%=@user.password-%>. For security reasons please change this on your first connection.

[....]

このバグが発生する理由について何か考えはありますか?ありがとう!

構成:Rails2.3.2およびDelayedJob2.0.4

4

1 に答える 1

2

問題がどこにあるかを見つけました。私はdelayed_jobsテーブルに作成されたエントリをデータベースで調べました。

  --- !ruby/struct:Delayed::PerformableMethod
  object: LOAD;Notifier
  method: :deliver_activation_instructions!
  args:
  - LOAD;User;589

パラメータは、user電子メールを送信する前に、delayed_jobによってデータベースから再ロードされます。その場合、パスワードはデータベースに保存されていないため、失われます。

そこで、パスワードを明示的に渡すためにコードを更新しました。

#app/models/notifier.rb 
def activation_instructions(user, password)
 from          default_email
 @bcc          = BACK_UP
 @subject      = "Activation instructions" 
 recipients    user.email
 sent_on       Time.now
 body          :root_url => root_url, :user => user, :password => password
end

#app/views/notifier/activation_instructions.erb
Thanks for signing up.

Your password is <%=@password-%>. For security reasons please change this on your first connection.

[....]

これが他の人にも役立つことを願っています!

于 2011-02-02T17:22:20.333 に答える