Forum: Ruby on Rails Updating a row in the database

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
thomazleite (Guest)
on 2007-06-08 00:16
(Received via mailing list)
What's the difference between updating an entry in the database using
the #save method and the #update method?

Thanks,
Thomaz
Cyril Mougel (Guest)
on 2007-06-08 00:38
(Received via mailing list)
On 6/8/07, thomazleite <thomazleite@gmail.com> 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 Mougel
Thomaz Leite (Guest)
on 2007-06-08 03:36
(Received via mailing list)
On 7 jun, 18:37, "Cyril Mougel" <cyril.mou...@gmail.com> wrote:
> On 6/8/07, thomazleite <thomazle...@gmail.com> 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.
Cyril Mougel (Guest)
on 2007-06-08 09:40
(Received via mailing list)
On 6/8/07, Thomaz Leite <thomazleite@gmail.com> 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 Mougel
This topic is locked and can not be replied to.