2017-09-12 8 views
0

私はdevise gemをインストールし、fullnamelocationの文字列としてデータベースにカスタムフィールドを追加しました。devises on Rails 5のカスタムフィールド

私はとしてeditnewフォームページを更新:

<%= f.input :fullname, required: true %> 
<%= f.input :location %> 

しかし、それは、このフィールドを保存したり、更新されません。

私は私が何をしないのですその enter image description here

のための任意のコントローラを見ることができませんか?私は数十のチュートリアルを通過しましたが、それを理解することはできません。

私はRails 5.1.3とRuby 2.4.0p0を使用しています。

答えて

1

フィルターの前にconfigure_permitted_parametersを使用すると、「怠惰な方法」で行うことができます。

ApplicationControllerに、devise_parameter_sanitizerで許可するキーを指定した保護されたメソッドを追加します。次に、使用されているコントローラが登録されているコントローラである場合は、このメソッドを指すbefore_actionコールバックを追加します。

class ApplicationController < ActionController::Base 
    before_action :configure_permitted_parameters, if: :devise_controller? 

    protected 

    def configure_permitted_parameters 
    permit_attrs(%i[fullname location]) 
    end 

    def permit_attrs(attrs) 
    %i[sign_up account_update].each do |action| 
     devise_parameter_sanitizer.permit(action, keys: attrs) 
    end 
    end 
end 
:あなたの場合、多分何かのように

関連する問題