2

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.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
drumwolf
  • 399
  • 1
  • 4
  • 16
  • 1
    possible duplicate of [How to specify devise\_parameter\_sanitizer for edit action?](http://stackoverflow.com/questions/19791531/how-to-specify-devise-parameter-sanitizer-for-edit-action) – wacko Jan 06 '14 at 23:59
  • Thank you to both wacko and Simone. That question (or more accurately, that answer) was EXACTLY what I was looking for. – drumwolf Jan 07 '14 at 00:48

1 Answers1

1

Adding this line to the "configure_permitted_parameters" method did the trick:

  devise_parameter_sanitizer.for(:account_update) << :username
drumwolf
  • 399
  • 1
  • 4
  • 16
  • I have this, and it still won't work. My username is the string `/edit` even though it's actually blank on the records – ahnbizcad Sep 13 '14 at 00:36