Best way to update attributes on AR objects without saving?

How about:

@ar_obj =[:id])
if @ar_obj.valid?
  # whatever code you need here for good objects
  # whatever code you have for erroneous information

AR is smart enough to figure out whether a record already exists by primary
key, so save will INSERT if it's a new record or UPDATE if it's an existing
one. Updating attributes skips straight to the database before giving you a
look. That's why creating from the params has is so powerful.

So what if you don't have a params hash? Make one:

@ar_obj ={:id => 3, :title = 'yippie skippy'})


athem wrote: