2016-04-17 11 views
0

私のユーザモデルに追加のフィールドを追加し、それに応じてconfigure_account_update_paramsメソッドを更新しました。ユーザーが現在のパスワードを入力しなくても情報を更新できるようになるまで、すべての作業が行われていました。Devise update_without_passwordがForbiddenAttributesErrorを返す

だから私は、ビューのフィールドを取り出して、これは私のコントローラであるRegistrationsController

で更新方法を変更し、私が考案するよると何か

class Users::RegistrationsController < Devise::RegistrationsController 
    before_filter :configure_account_update_params, only: [:update] 

    def update 
    resource.update_without_password(resource_params) 
    end 

    # If you have extra params to permit, append them to the sanitizer. 
    def configure_account_update_params 
    devise_parameter_sanitizer.for(:account_update) << [:first_name, :last_name, :country, :phone_number, :gender, :birthdate] 
    end 
end 

答えて

1

を欠けている場合、私はわからないんだけどマニュアルでは、コントローラでこれを置き換える必要があります。

class Users::RegistrationsController < Devise::RegistrationsController 

     protected 

     def update_resource(resource, params) 
     resource.update_without_password(params) 
     end 
    end 
+0

「configure_account_update_params」と一緒にそれを行いました。ありがとう –

関連する問題