开发者

Database write delayed in rails controller?

I'm using authlogic to generate a perishable token and send it on to the user for activation of his account, and send the mail later in a delayed job. Like so:

  def deliver_activation_instructions!
    reset_perishable_token!
    Notifier.send_later(:deliver_activation_instructi开发者_Python百科ons, self)
  end

What I'm seeing is that the perishable token written by the 'reset_perishable_token' call is not the one that has been emailed to the user. If I'm using send_later, is there a chance that the worker will pick up old values from the database? I thought that the Notifier.send_later call would only occur after the token had been written.... Or is there something I don't understand about how this works?


To answer my question, the problem was not a bad database write - it was that the authlogic library automatically updates the perishable token every time you save the database record. I was sending the token, then saving the user record which reset the token! There is a config setting that I needed: disable_perishable_token_maintenance = true

That did the trick and fixed my bug

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜