在 rails c 中数据不能输入,显示 bcrypt-ruby 在 gemfile 中没有添加,但是我这里已经添加。
准备过一遍 rspec 的功能,因此学习了 every rails testing with rspec,代码为:
https://github.com/everydayrails/rspec_rails_4
因为页面没有提供注册的入口,因此在打开 rails c 输入如下的代码:
user = User.create(email: "[email protected]", password: "111111", password_confirmation: "111111", admin: "1")
回车显示是 bcrypt-ruby 没有添加到 gemfile 文件中,但是我的 gemfile 文件中已经有了这个 gem,多次尝试均是这个结果。
因为求问原因
user = User.create(email: "[email protected]", password: "111111", password_confirmation: "111111", admin: "1")
password_confirmation 是必须的么? 是不是只要 User.create(email: "[email protected]", password: "111111", admin: "1") 就可以了?
#9 楼 @lmorenbit 这是因为在 User 这个 model 里面添加了 has_secure_password 方法,会默认添加 password 和 password_confirmation 两个字段,并且判断两个字段的内容是否相同。
#13 楼 @lmorenbit it is available by the condition of devise, it is useless on this occasion