A
A
A_Modestov2016-02-03 08:06:22
Ruby on Rails
A_Modestov, 2016-02-03 08:06:22

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

2 answer(s)
B
bukovki, 2016-02-03
@A_Modestov

For example, like this:

devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:avatar, :name,...) }

D
Dmitry, 2016-03-04
@svetozar

Or so :)

devise_parameter_sanitizer.for(:sign_up) << :avatar << :name
devise_parameter_sanitizer.for(:account_update) << :avatar << :name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question