Unable to update user attributes - Rails and Devise

I am using Rails (3.0.9) with Devise (1.5.3), and I have a User model in which attributes cannot be updated for some reason that I don’t know about.

The form for this user object has many attributes, including those from devise: password and password_confirmation, for example.

When I submit the form, I get it in the registrar:

WARNING: Can't mass-assign protected attributes: current_password

But when I add current_password to attr_accessible , I get:

ActiveRecord::UnknownAttributeError at /users unknown attribute: current_password

I am not very good at Devise, but I think current_password is just a virtual attribute. This mistake is very annoying, do you know why this is happening? I dont know.

By the way, my Users::RegistrationsController#update action:

 def update logger.error "SALMONELLA " + self.resource.password.inspect self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key) #params[:user].delete [:current_password] if resource.update_attributes(params[:user]) Resque.enqueue(MdcUpdateUser, resource.id) set_flash_message :notice, :updated if is_navigational_format? sign_in resource_name, resource, :bypass => true respond_with resource, :location => after_update_path_for(resource) else clean_up_passwords(resource) respond_with_navigational(resource){ render_with_scope :edit } end end 

I tried using Devise update_without_password and also tried to remove current_password from the params[:user] hash, but was unsuccessful.

I appreciate any help you give me. Please request additional information if you think that there is no information on this issue.

+4
ruby ruby-on-rails activerecord devise
source share
1 answer

Then you may have to add attr_accessor :current_password to your model. Also see the Devise Wiki and this issue for further understanding.

+7
source share

All Articles