Add a field to configure user registration

I am using Devise with my Ruby on Rails 4 application to authenticate / register users. I want to add another field to my user registration form called nickname . Adding this field to the views is straightforward, but what is the best thing to do next and ensure that Devise ensures that it is saved in the model and does not reject this attribute, since it is non-standard for it to be created?

+4
source share
1 answer

If it rejects the attribute, I assume that you need to add it to the application controller.

  def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:nickname) } devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:nickname, :email, :password) } end 

I hope you are talking about this.

+4
source

Source: https://habr.com/ru/post/1499041/


All Articles