用户登录章节,

书上的代码会报错,Can’t mass-assign protected attributes: password_confirmation。

解决办法:

 

在rails3.2中,自动生成脚手架的话,app/models/user.rb中有这么一行

1 attr_accessible  :name, :hashed_password,:salt

需在后面加上:password_confirmation和:password两项属性。即

attr_accessible  :name, :password_confirmation,:password,:hashed_password,:salt

 

参考:http://www.cnblogs.com/suprise/

相关文章:

  • 2021-08-23
  • 2021-06-04
  • 2021-06-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2021-10-05
  • 2021-11-27
相关资源
相似解决方案