# Updating a row in the database

**URL:** <https://www.ruby-forum.com/t/updating-a-row-in-the-database/106274>\
**Category:** Rails\
**Created:** [June 8, 2007, 12:16am UTC](https://www.ruby-forum.com/t/updating-a-row-in-the-database/106274 "2007-06-08T00:16:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomazleite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@thomazleite](https://www.ruby-forum.com/u/thomazleite)\
**Post date:** [June 8, 2007, 12:16am UTC](https://www.ruby-forum.com/t/updating-a-row-in-the-database/106274/1 "2007-06-08T00:16:48Z")

</div>

What’s the difference between updating an entry in the database using  
the #save method and the #update method?

Thanks,  
Thomaz

---

<div class="post-metadata">

**Author:** ![thomazleite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@thomazleite](https://www.ruby-forum.com/u/thomazleite)\
**Post date:** [June 8, 2007, 12:38am UTC](https://www.ruby-forum.com/t/updating-a-row-in-the-database/106274/2 "2007-06-08T00:38:49Z")

</div>

On 6/8/07, thomazleite [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> What’s the difference between updating an entry in the database using  
> the #save method and the #update method?

A save made a check for see if the Object exist or not. If exist, the  
Object is save else, it’s update.

With the #update, you must use a id who exist and define the attribute  
to update. And it’s a public classe Method not instance method, so you  
use it only with Name class, not with your Object.

–  
Cyril M.

---

<div class="post-metadata">

**Author:** ![thomazleite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@thomazleite](https://www.ruby-forum.com/u/thomazleite)\
**Post date:** [June 8, 2007, 3:36am UTC](https://www.ruby-forum.com/t/updating-a-row-in-the-database/106274/3 "2007-06-08T03:36:07Z")

</div>

On 7 jun, 18:37, “Cyril M.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On 6/8/07, thomazleite [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> A save made a check for see if the Object exist or not. If exist, the  
> Object is save else, it’s update.
> 
> With the #update, you must use a id who exist and define the attribute  
> to update. And it’s a public classe Method not instance method, so you  
> use it only with Name class, not with your Object.

I’m coding a change password method in my application. When I use  
#update, a invalid password gets saved. The same doesn’t happens with  
#save.

---

<div class="post-metadata">

**Author:** ![thomazleite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@thomazleite](https://www.ruby-forum.com/u/thomazleite)\
**Post date:** [June 8, 2007, 9:40am UTC](https://www.ruby-forum.com/t/updating-a-row-in-the-database/106274/4 "2007-06-08T09:40:37Z")

</div>

On 6/8/07, Thomaz L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m coding a change password method in my application. When I use  
> #update, a invalid password gets saved. The same doesn’t happens with  
> #save.

How use you update method ?

–  
Cyril M.
