Creating a new User Model - wordjelly/Auth GitHub Wiki
Checklist for creating a new model
- Include the Auth::UserConcern
- Create a parameter_sanitizer.rb, and place it in lib/model_name/parameter_sanitizer.rb. Here name is an optional attribute that I added onto the model, you can add any number of such attributes, but all of them have to be specified in the parameter sanitizer.
`
class User::ParameterSanitizer < Devise::ParameterSanitizer
def initialize(resource_class, resource_name, params)
super(resource_class, resource_name, params)
permit(:sign_up, keys: Auth.configuration.auth_resources[resource_class.to_s][:login_params] + [:name])
permit(:account_update, keys: Auth.configuration.auth_resources[resource_class.to_s][:login_params] + [:name])
end
end
`
-
Then in the ApplicationController make sure to add the following block `
protected def devise_parameter_sanitizer if resource_class == User User::ParameterSanitizer.new(User, :user, params) elsif resource_class == Admin Admin::ParameterSanitizer.new(Admin,:admin,params) else super # Use the default one end end
`
- In the preinitializer file specify the key :login_params , this can be either just [:email], or [:email,:additional_login_param]