我正在尝试为测试加载一个具有密码列(二进制数据类型)的灯具。我使用的工具使用EzCrypto gem在存储/检索密码之前对密码进行加密和解密。现在,如果我的列是二进制的,我认为Rails会自动将密码存储为加密的-但我得到的只是:

1。

Error:
 test_is_working(FirstTest):
 RuntimeError: Failed to decode the field. Incorrect key?
/Library/Ruby/Gems/1.8/gems/mislav-will_paginate 2.3.11/lib/will_paginate/finder.rb:170:in 'method_missing'
unit/first_test.rb:8:in setup


2。

Error:
test_sanity(FirstTest):
RuntimeError: Failed to decode the field. Incorrect key?
    unit/first_test.rb:8:in `setup'


    Fixture file looks like this:
    first_hussle:
        type: FirstAccount
        user: jsewq
        username: abc@mac.com
        password: 'abc123'


有什么线索吗?

最佳答案

您需要使用ezcrypto对设备中的密码进行加密。假设您的装置是用于users表的,并且已经定义了user_crypto_provider.rb文件/类。

password: <%= UserCryptoProvider.encrypt('abc123') %>

关于ruby-on-rails - Ruby Fixtures错误,密码列,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2956158/

10-11 22:16
查看更多