w25x
w25x

Reputation: 65

Devise with rails 4 not updating user

I upgraded an app to rails 4 and everything is working fine. I can sign in and goto my edit page. Also updated the views. When using the standard view, the user is updated. But when I add for example the field :name, this is not updated in the form.

Using devise 3.1.1 and also the gem 'protected_attributes'

Do I need to run some kind of update command on devise or db?

I have also searched this place, finding many different solution, but none will update my user field. I have not added any custom fields.

Upvotes: 5

Views: 1716

Answers (1)

zeroed
zeroed

Reputation: 548

If you want to permit additional parameters you can use a before filter in your ApplicationController because Rails 4 moved the parameter sanitization from the model to the controller.

class ApplicationController < ActionController::Base
  before_filter :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) << :name << :surname << :username
    devise_parameter_sanitizer.for(:account_update) << :name << :surname << :username
  end
end

You can also find more here.

Upvotes: 8

Related Questions