Authlogic + Factory Girl:验证失败:密码太短(最少 4 个字符)
Authlogic + Factory Girl: Validation failed: Password is too short (minimum is 4 characters)
我正在尝试为使用 authlogic 定义的 "account" 模型构建工厂:
class Account < UuidEnabled
acts_as_authentic do |c|
c.validate_password_field = true
c.require_password_confirmation = true
c.ignore_blank_passwords = false
c.crypto_provider = Authlogic::CryptoProviders::Sha512
end
end
这是我的工厂:
FactoryGirl.define do
factory :account do
sequence(:email) { |n| "account_#{n}@example.com"}
password = "1234"
password_confirmation { |a| a.password} # to make things work even if the password is changed
end
end
我的测试失败
ActiveRecord::RecordInvalid: Validation failed: Password is too short (minimum is 4 characters), Password confirmation is too short (minimum is 4 characters)
您是否尝试过在帐户模型中设置 attr_accessible :password
?
认为这只是一个错字,尝试:
FactoryGirl.define do
factory :account do
sequence(:email) { |n| "account_#{n}@example.com"}
password "1234"
password_confirmation { |a| a.password} # to make things work even if the password is changed
end
end
注意password
后面的等号已经去掉
我正在尝试为使用 authlogic 定义的 "account" 模型构建工厂:
class Account < UuidEnabled
acts_as_authentic do |c|
c.validate_password_field = true
c.require_password_confirmation = true
c.ignore_blank_passwords = false
c.crypto_provider = Authlogic::CryptoProviders::Sha512
end
end
这是我的工厂:
FactoryGirl.define do
factory :account do
sequence(:email) { |n| "account_#{n}@example.com"}
password = "1234"
password_confirmation { |a| a.password} # to make things work even if the password is changed
end
end
我的测试失败
ActiveRecord::RecordInvalid: Validation failed: Password is too short (minimum is 4 characters), Password confirmation is too short (minimum is 4 characters)
您是否尝试过在帐户模型中设置 attr_accessible :password
?
认为这只是一个错字,尝试:
FactoryGirl.define do
factory :account do
sequence(:email) { |n| "account_#{n}@example.com"}
password "1234"
password_confirmation { |a| a.password} # to make things work even if the password is changed
end
end
注意password
后面的等号已经去掉