當用戶進行註冊,並按報名我得到這個錯誤未經許可參數添加新的領域,以在軌設計
undefined method `for' for #<Devise::ParameterSanitizer:0x007fe4c2821988> Did you mean? fork
}
elsif params[:action] == 'create'
devise_parameter_sanitizer.for(:sign_up) {
|u| u.permit(registration_params)
}
end
這是我的應用程序控制器
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_devise_permitted_parameters, if: :devise_controller?
protected
def configure_devise_permitted_parameters
registration_params = [
:first_name, :last_name, :address, :gender, :DOB,
:email, :password, :password_confirmation,
:image, :thumb, :medium
]
if params[:action] == 'update'
devise_parameter_sanitizer.for(:account_update) {
|u| u.permit(registration_params << :current_password)
}
elsif params[:action] == 'create'
devise_parameter_sanitizer.for(:sign_up) {
|u| u.permit(registration_params)
}
end
end
end
我能知道是什麼是問題以及如何解決它
你想達到什麼樣的? – uzaif