rails activerecord save method

Posted by Yang on Stack Overflow See other posts from Stack Overflow or by Yang
Published on 2010-03-24T03:05:54Z Indexed on 2010/03/24 3:13 UTC
Read the original article Hit count: 338

Filed under:
|

hi, guys, can the save method be used to update a record?

person = Person.new 
person.save # rails will insert the new record into the database.

however, if i find a record first, modify it and save it. is it the same as performing a update?

person = Person.find(:first, :condition => "id = 1") 
person.name = "my_new_name" 
person.save # is this save performing a update or insert?

Thanks in advance!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about activerecord