views:

53

answers:

1

Hi,

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_instructions, 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?

A: 

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

cmaughan