Hi all, I use save on an ActiveRecord object to insert or update it. I expect save to insert a new object in the database when I didn''t assign the id to the object and update the object when I assigned an id to it. That''s what I think the documentation tells me: * No record exists: Creates a new record with values matching those of the object attributes. * A record does exist: Updates the record with values matching those of the object attributes. Shouldn''t it update the record when the id already exists or have I misunderstood how save works? regards, Stijn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
yes, you misunderstood this detail when you create a new model object with eg User.new, Rails uses (I assume) an internal flag to determine, that this is a new record. If you load a record with User.find (eg) this flag is off. So that''s a Rails internal state, setting the ID field has nothing to do with it, it only depends on the way the object was created. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---