【发布时间】:2016-10-28 12:23:51
【问题描述】:
我正在使用 gem Devise 向我的模型用户添加一个全名(字符串)值。
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
include Authorization
protect_from_forgery with: :exception
end
还有
# app/controllers/concerns/Authorization.rb
module Authentication
extend ActiveSupport::Concern
private
def devise_parameter_sanitizer
if resource_class == User
User::ParameterSanitizer.new(User, :user, params)
else
super
end
end
end
# app/controllers/sanitizers/user/parameter_sanitizer.rb
class User
class ParameterSanitizer < Devise::ParameterSanitizer
USER_PARAMS = %i(
full_name
email
password
password_confirmation
).freeze
def sign_up
default_params.permit(USER_PARAMS)
end
def account_update
default_params.permit(USER_PARAMS)
end
end
end
一切正常,但我在创建用户时出错Unpermitted parameter: full_name
有什么想法吗?
【问题讨论】:
标签: ruby-on-rails devise strong-parameters