Best way to update attributes on AR objects without saving?

How about:

@ar_obj = ArObj.new(params[:id])
if @ar_obj.valid?
  # whatever code you need here for good objects
  @ar_obj.save
else
  # whatever code you have for erroneous information
end

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 = ArObj.new({:id => 3, :title = 'yippie skippy'})

Yes?

athem wrote: