devise - 没有将 Symbol 隐式转换为 Integer

标签 devise ruby-on-rails-4 implicit-conversion

我正在使用 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/

相关文章:

ruby-on-rails - 为什么我们需要在这个 Rails try block 中使用问号?

sql - 在查询的选择中传递参数

c++ - std::string const& 参数是否复制传递的 const char* ?

c++ - 没有从 std::function 到 bool 的可行转换

jquery - Devise on Rails 3 的注销链接

ruby-on-rails - 设计更改密码不起作用(未知属性 : current_password)

ruby-on-rails - application.html.erb 根据用户所在的页面呈现不同的部分

c# - Xamarin.Forms 绑定(bind) - 隐式类型转换是否在代码中完成,而不是在 XAML 中完成?

ruby-on-rails - 如何使用无效的用户凭据实现 RSpec session Controller 测试

关于 Selenium-Webdriver 的 RSpec 错误