2014-02-13 55 views
3

我使用rails 4.0.1和ruby 2.0.0與devise 3.2.2。當用戶嘗試編輯他的帳戶時,我不斷收到此問題。我有我的application_controller.rb和自定義更新控制器,它看起來像這樣強大的參數:沒有將Symbol隱式轉換爲Integer

類RegistrationsController <設計:: 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 

保護 高清after_update_path_for(資源) user_path(資源) 結束 結束

我一直在拉我的頭髮,因爲昨天...任何援助將不勝感激。讓我知道你是否需要更多信息。

被修改: 在我注意到錯誤之前,唯一改變的地方是設計開始在設計初始化文件時要求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' 

謝謝!

回答

6

我在幾個小時後解決了問題。希望這可以幫助那裏的人。似乎Devise改變了它的文檔。無論如何,我除去這一行:

account_update_params = devise_parameter_sanitizer.for(:account_update的)

和改變這一行:

如果@ user.update_with_password(account_update_params)

如果@ user.update_with_password(devise_parameter_sanitizer.sanitize(:account_update))

每個事情工作..現在我需要一杯飲料。

+0

如果我可以upvote這1000倍,我會 – hobberwickey

相關問題