Reputation: 409
I'm using Devise to implement user authentication, and I've added a custom "username" field. I was able to get the user registration form to edit the username field by putting this code in my application controller:
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) << :username
end
Now I'm trying to implement another form to edit an already existing user account, and now that form won't work for editing a user's username field.
I have a hunch that I need to add another line of code in the "configure_permitted_parameters" method above, but I tried out things like "devise_parameter_sanitizer.for(:account_update) << : account_update" and it didn't work.
What should I do to get the "update account" form to edit usernames? Like I said, the "new user signup" form is working fine in that regard.
Upvotes: 2
Views: 672
Reputation: 409
Adding this line to the "configure_permitted_parameters" method did the trick:
devise_parameter_sanitizer.for(:account_update) << :username
Upvotes: 1