1

パスワード列(バイナリデータ型)を持つテスト用のフィクスチャをロードしようとしています。私が使用しているツールは、EzCrypto gemを使用して、パスワードを保存/取得する前に暗号化および復号化します。私の列がバイナリの場合、railsはパスワードを暗号化されたものとして自動的に保存すると思いましたが、取得できるのは次のとおりです。

1.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.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'

手がかりはありますか?

4

1 に答える 1

0

フィクスチャのパスワードを暗号化するには、ezcrypto を使用する必要があります。user_crypto_provider.rbフィクスチャが users テーブル用であり、ファイル/クラスが定義されていると仮定します。

password: <%= UserCryptoProvider.encrypt('abc123') %>
于 2010-10-10T18:23:50.737 に答える