Devise Confirmations Called Twice Using AutoBuild

200 Views Asked by At

I've had a problem that when using AutoBuild with Devise confirmable the confirmation codes within the emails are invalid. I found that this is because the confirmation code is generated for the model then the email is rendered. After that the AutoBuilt model is created and added to the parent model but the confirmation code is generated again during this operation, but the old code is still rendered in the email and is sent to the user therefore the user never gets the new confirmation code.

Here are my MOPED commands from the development.log

  MOPED: 127.0.0.1:27017 INSERT       database=myapp_development collection=developers documents=[{"_id"=>BSON::ObjectId('52b4c8354372690311040000'), "email"=>"[email protected]", "encrypted_password"=>"$2a$10$9VLgfHEBAve5aRgkYW0k3.pXkVwuTRgzT5RMiDhn0pNqNLJv8XZJa", "sign_in_count"=>0, "failed_attempts"=>0, "company"=>"Testing", "provider"=>"github", "uid"=>"4883802", "confirmation_token"=>"08f6209f0ed00e4e494ce15ac472cedce52afee7485372f1123264af92053447", "confirmation_sent_at"=>2013-12-20 22:44:05 UTC}] flags=[]
  MOPED: 127.0.0.1:27017 UPDATE       database=myapp_development collection=developers selector={"_id"=>BSON::ObjectId('52b4c8354372690311040000')} update={"$set"=>{"encrypted_password"=>"$2a$10$9VLgfHEBAve5aRgkYW0k3.pXkVwuTRgzT5RMiDhn0pNqNLJv8XZJa", "sign_in_count"=>0, "failed_attempts"=>0, "company"=>"Testing", "provider"=>"github", "uid"=>"4883802", "confirmation_token"=>"c2d377599784b34bc9959eb43106f57e60642c5acb53ca93f19cc85b78c57de1", "confirmation_sent_at"=>2013-12-20 22:44:05 UTC, "unconfirmed_email"=>"[email protected]"}} flags=[]

In my Devise model I'm calling AutoBuild on a has_one relationship. The minute I remove AutoBuild the code works but half of my application is broken. How come AutoBuild is causing the confirmation token to be recreated? Any suggestions?

0

There are 0 best solutions below