# Update method

**URL:** <https://www.ruby-forum.com/t/update-method/114103>\
**Category:** Rails\
**Created:** [September 7, 2007, 11:04pm UTC](https://www.ruby-forum.com/t/update-method/114103 "2007-09-07T23:04:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rich](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/35a633/32.png) [@rich](https://www.ruby-forum.com/u/rich)\
**Post date:** [September 7, 2007, 11:04pm UTC](https://www.ruby-forum.com/t/update-method/114103/1 "2007-09-07T23:04:50Z")

</div>

I have a question on updating records. I have this User model that  
requires a password in order to save. In the database there is the  
password hash and salt so I don’t save the password. However, when I  
retrieve a user record and try to update using the save function it  
would not update. I assume because the password attribute is  
automatically set to nil when retrieving a record.

Since I cannot use save, I tried the update method. For example if I  
type on the console

u=User.find(1)  
u.name=“whatever”  
u.update

This worked but I realized that the update method is not part of the  
rails API. There are only four update type methods in  
ActiveRecord::Base, update(:id, attributes), update\_all(updates,  
conditions=nil), update\_attribute, and update\_attributes.

So my questions are

1. Why does update (without any arguments) work since it is not part  
of the API documentation?
2. Why does update\_attributes not work in updating my user record but  
update\_attribute works for one field?
3. Do you know a good way if I want to update my User record if I want  
to update more than one field? I don’t mind using the update method w/  
o parameters but I wonder if it is deprecated.

Thanks.  
-Rich
