我创建了一个Comapny模型,我希望它能够使用devise进行sign_up。
以下是代码:
lib/sanitizers/company_sanitizer.rb
class Company::ParameterSanitizer < Devise::ParameterSanitizer
def sign_in
default_params.permit(:subdomain, :plan, :email)
end
end
\
config/initializers/sanitizers.rb
require "#{Rails.application.root}/lib/sanitizers/company_sanitizer.rb"
最后是application_controller.rb
protected
def devise_parameter_sanitizer
if resource_class == Company
Company::ParameterSanitizer.new(Company, :company, params)
else
super
end
end
现在,麻烦的是那些额外的参数被忽略了:
log/development.log
Unpermitted parameters: plan, subdomain
我做错了什么,我无法弄明白!?