参见英文答案 >
how does activerecord know to perform an insert or update?3
家伙,可以用save方法来更新一个记录吗?
家伙,可以用save方法来更新一个记录吗?
person = Person.new person.save # rails will insert the new record into the database.
但是,如果我先找到记录,修改它并保存.是否与执行更新相同?
person = Person.find(:first,:condition => "id = 1") person.name = "my_new_name" person.save # is this save performing a update or insert?
提前致谢!