I'm just diving into ActiveRecord and have not been able to find an answer to my question. If I am updating an object's attributes and then calling save()... will ActiveRecord save to the DB ONLY when the new values are different from the old values?
Let's say I do something like this:
thing_to_update = Thing.find_or_create_by_code(some_code)
if thing_to_update.name != some_name
thing_to_update.update_attribute(:name, some_name)
end
I don't want to do extra calls to the db if I don't have to because I will potentially have to update a lot of objects. I tried to read through the docs and it doesn't mention anything about comparing new values with the old ones. Am I missing something here?
Thanks