On Oct 6, 11:46 pm, Bjoern <[email protected]> wrote: > > then, if I try dm.save! with a self-sent message (so recipient = > sender), I get an SQL error, because user id should be unique. It > seems in this case ActiveRecord attempts to save the objects with an > INSERT statement. > > Is there a way to make it update the record if the object already > exists in the db, and otherwise create it?
If that's what you want then you should attempt to load the appropriate object first, create a new one if you can't find one and then save (see also the dynamic finders - http://api.rubyonrails.org/classes/ActiveRecord/Base.html ) Fred > > Also other comments to my approach are welcome, as I am fairly new to > Rails. > > Thanks! > > Björn > > I get the error --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

