我正在使用 Rails 4.0.1 和 ruby 2.0.0 以及 devise 3.2.2。当用户尝试编辑他的帐户时,我不断遇到此问题。我在 application_controller.rb 中有强大的参数和自定义更新 Controller ,如下所示:
类 RegistrationsController < Devise::RegistrationsController
def update
# For Rails 4
account_update_params = devise_parameter_sanitizer.for(:account_update)
@user = User.find(current_user.id)
@user.balanced_associate_token_with_customer(account_update_params)
if @user.update_with_password(account_update_params)
set_flash_message :notice, :updated
# Sign in the user bypassing validation in case his password changed
sign_in @user, :bypass => true
redirect_to after_update_path_for(@user)
else
render "edit"
end
end
protected def after_update_path_for(资源) 用户路径(资源) 结尾 结束
从昨天起我就一直在烦恼......任何帮助将不胜感激。如果您需要更多信息,请告诉我。
编辑: 在我注意到错误之前唯一发生变化的是,设计开始在设计初始化文件中请求 config.secret_key。
完整跟踪的一部分显示:
devise (3.2.2) lib/devise/models/database_authenticatable.rb:64:in `[]'
devise (3.2.2) lib/devise/models/database_authenticatable.rb:64:in `update_with_password'
app/controllers/registrations_controller.rb:12:in `update'
actionpack (4.0.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.0.2) lib/abstract_controller/base.rb:189:in `process_action'
谢谢!
最佳答案
几个小时后我解决了这个问题。希望这对那里的人有帮助。似乎 Devise 更改了其文档。不管怎样,我删除了这一行:
account_update_params = devise_parameter_sanitizer.for(:account_update)
并更改了这一行:
如果@user.update_with_password(account_update_params)
至
if @user.update_with_password(devise_parameter_sanitizer.sanitize(:account_update))
一切正常......现在我需要喝一杯。
关于devise - 没有将 Symbol 隐式转换为 Integer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21764140/