Answer the question
In order to leave comments, you need to log in
How to add properties to Devise model?
Good day everyone. The question is the following: I use the devise gem to authorize the user, I want to add the properties :avatar, :name to the model. When a user is created, the properties are accepted, when they are updated they are not. How to pass them to the update method?
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
protect_from_forgery with: :exception
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) << :avatar
devise_parameter_sanitizer.for(:sign_up) << :name
devise_parameter_sanitizer.for(:sign_up) << :avatar
devise_parameter_sanitizer.for(:sign_up) << :name
end
end
Answer the question
In order to leave comments, you need to log in
For example, like this:
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:avatar, :name,...) }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question