I just dive into ActiveRecord and cannot find the answer to my question. If I update the attributes of an object and then call save () ... will ActiveRecord only be saved in the database when the new values ββdiffer from the old values?
Say I'm doing 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 do not want to make additional calls in db if I do not need it, because I will probably have to update many objects. I tried to read the docs and it says nothing about comparing new values ββwith old ones. Did I miss something?
thanks
ruby ruby-on-rails activerecord
Ryan ferretti
source share