Ruby on rails 具有\u安全\u密码的模型无法创建
有人知道为什么使用安全密码在简单模型上创建失败吗 我有rails 4.0.2 我有一个非常简单的模型: $rails g资源提供程序名称密码\u摘要 使用models/provider.rbRuby on rails 具有\u安全\u密码的模型无法创建,ruby-on-rails,Ruby On Rails,有人知道为什么使用安全密码在简单模型上创建失败吗 我有rails 4.0.2 我有一个非常简单的模型: $rails g资源提供程序名称密码\u摘要 使用models/provider.rb class Provider < ActiveRecord::Base has_secure_password end 使用rails控制台,我尝试创建一个模型: 2.0.0-p353 :013 > Provider.create(name: "boot", password: "
class Provider < ActiveRecord::Base
has_secure_password
end
使用rails控制台,我尝试创建一个模型:
2.0.0-p353 :013 > Provider.create(name: "boot", password: "Boot1234tooB")
(0.1ms) begin transaction
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
(0.1ms) rollback transaction
=> #<Provider id: nil, name: "boot", password_digest: "$2a$10$yOkRGwFioJVhZTwiEKTQseGsHM9vQ82UAPAkkF4FGUwX...", created_at: nil, updated_at: nil>
2.0.0-p353 :014 > print Provider.all.to_yaml
Provider Load (4.7ms) SELECT "providers".* FROM "providers"
--- []
=> nil
谢谢
Rob您应该设置密码确认:
更多关于
Provider.create(name: "boot", password: "Boot1234tooB", password_confirmation: "Boot1234tooB")