2017-09-12 6 views
0

나는 devise gem을 설치하고 fullnamelocation의 데이터베이스에 사용자 정의 필드를 문자열로 추가했습니다.devises on Rails 5의 사용자 정의 필드

나뿐만 editnew 양식 페이지 업데이트 :

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

을하지만 저장하거나이 필드를 업데이트하지 않습니다.

나는 무엇을 놓치고 그 enter image description here

에 대한 컨트롤러를 볼 수없는 이유는 무엇입니까? 수십 개의 자습서를 거쳤지만 알아낼 수는 없습니다.

레일 5.1.3 및 루비 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 
: 귀하의 경우 아마도 뭔가 같은에서