Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 899
w25x Avatar asked Oct 18 '13 17:10

w25x


1 Answers

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.

like image 172
zeroed Avatar answered Sep 28 '22 08:09

zeroed