简体   繁体   English

attr_encrypted没有保存到数据库

[英]attr_encrypted not saving to database

Ruby 1.9.2p180, Rails 3.0.8, attr_encrypted 1.2.0 Ruby 1.9.2p180,Rails 3.0.8,attr_encrypted 1.2.0

So, in my model I have the following: 所以,在我的模型中,我有以下内容:

attr_encryptor :email, :key => "awesome_key"

And in the database I have a text column named "encrypted_email". 在数据库中,我有一个名为“encrypted_email”的文本列。

In the console, everything works in memory. 在控制台中,一切都在内存中运行。 The encrypted_email attribute is updated with the encrypted version and everything. 使用加密版本和所有内容更新encrypted_email属性。 But when I go to save it, nothing happens. 但是当我去保存它时,没有任何反应。

While messing around with it I discovered that the model's changes hash does not reflect the changes to encrypted_email, even if I try to set the value manually. 在搞乱它时,我发现模型的更改哈希并不反映encrypted_email的更改,即使我尝试手动设置值。

Am I doing something wrong here or is attr_encrypted broken? 我在这里做错了还是attr_encrypted坏了? Does anyone know how things get added to the changes hash? 有谁知道如何将事物添加到更改哈希? Is there some method call or something that I could add the setter methods that attr_encrypted generates so that changes show up in the hash? 是否有一些方法调用或其他东西,我可以添加attr_encrypted生成的setter方法,以便更改显示在哈希?

Thanks! 谢谢!

It looks like the community fixed the bug. 看起来社区修复了这个bug。 Back when I was trying to make it work I just in the wrong place at the wrong time apparently :-) 回来当我试图让它工作时,我只是在错误的时间在错误的地方显然:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM