Whatever.all(:something => true).update!(:something => false) => UPDATE whatevers SET something = false WHERE something = true
On Sat, Dec 6, 2008 at 12:02 PM, cult hero <[EMAIL PROTECTED]> wrote: > > Hey everyone. I just started playing with DataMapper yesterday and am, > more or less, just getting my feet wet. I read through the docs on the > site which gave me enough to start working with. However, there was > one thing in particular that seemed simple that I couldn't find an > example for doing. > > What if I want to update a record without selecting it first? > > For instance, last night I took two tables from another project and > combined them into one for DataMapper. The old project's ORM (which > will remain unnamed) did not support lazy loading, so I kept a text > field related to the rest of the data in its own table. When I merged > the two last night, I had a ruby script read the contents of the first > table and insert them, but to bring the text fields in from the other > table my script effectively had to do this: > > SELECT * FROM Table WHERE PriKey = X > UPDATE Table SET TextField = Y WHERE PriKey = X > > Is there a way to say: "Hey DataMapper, update a particular attribute > of a model with an equivalent WHERE clause."? > > I'm sure there is. I either spaced it when reading or didn't get it. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" 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/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
