我遇到了一个问题,当使用 AutoBuild 和 Devise 可确认时,电子邮件中的确认代码无效。我发现这是因为为模型生成了确认码,然后呈现了电子邮件。之后创建 AutoBuilt 模型并将其添加到父模型,但在此操作期间再次生成确认码,但旧代码仍呈现在电子邮件中并发送给用户,因此用户永远不会收到新的确认码。
这是我在 development.log 中的 MOPED 命令
MOPED: 127.0.0.1:27017 INSERT database=myapp_development collection=developers documents=[{"_id"=>BSON::ObjectId('52b4c8354372690311040000'), "email"=>"vincent@me.com", "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"=>"vincent@me.com"}} flags=[]
在我的设计模型中,我在 has_one 关系上调用 AutoBuild。我删除 AutoBuild 的那一刻,代码可以工作,但我的应用程序有一半坏了。为什么 AutoBuild 会导致重新创建确认令牌?有什么建议么?