我仍然是Rails的初学者,并且已经搜索了一段时间的答案。我在我的应用中使用Devise进行身份验证,并希望用户能够在不使用当前密码的情况下更新其帐户信息。我已经看过 allowing users to edit their account without providing a password上的Devise文档。如何在没有密码的情况下编辑用户使用设计
在这样做时,我会遇到一些错误。无论哪个控制器设置(通过提供的文档)提交帐户更新时,我用的,我得到这个:
Can't mass-assign protected attributes: current_password
所以,我去我的用户模型,并添加:current_password到attr_accessible。然后当提交更新时,我会看到:
unknown attribute: current_password
所以,我卡住了。我无法弄清楚交易是什么。我90%确定我有routes.rb正确设置(再次,遵循文档)。我在想,如果我没有,这些错误信息甚至不会出现。
你能告诉我们你的模型行
<%= f.input :current_password %>
?你使用的是mongoid还是ActiveRecord? –尝试并添加以下'attr_accessor:current_password' – David
@GeraudMathe我正在使用ActiveRecord。 – anater