diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-07-24 20:20:03 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-07-24 20:20:26 -0300 |
commit | 2d9e5a26a10e5f83f9b3ac465bd45b2e15a0bc2a (patch) | |
tree | 08bd5ed78f12c3aecac9295889874cb9b0956294 /activerecord/lib/active_record | |
parent | da84ccb6f04080d0f18f9bce35f773f193b1770b (diff) | |
download | rails-2d9e5a26a10e5f83f9b3ac465bd45b2e15a0bc2a.tar.gz rails-2d9e5a26a10e5f83f9b3ac465bd45b2e15a0bc2a.tar.bz2 rails-2d9e5a26a10e5f83f9b3ac465bd45b2e15a0bc2a.zip |
Deprecate update_column in favor of update_columns.
Closes #1190
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/has_one_association.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb index f0d1120c68..7086dfa34c 100644 --- a/activerecord/lib/active_record/associations/has_one_association.rb +++ b/activerecord/lib/active_record/associations/has_one_association.rb @@ -36,7 +36,7 @@ module ActiveRecord when :destroy target.destroy when :nullify - target.update_column(reflection.foreign_key, nil) + target.update_columns(reflection.foreign_key => nil) end end end diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index e34dc11606..2830d651ba 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -204,6 +204,11 @@ module ActiveRecord # Raises an +ActiveRecordError+ when called on new objects, or when the +name+ # attribute is marked as readonly. def update_column(name, value) + msg = "update_column is deprecated and will be removed in 4.1. Please use update_columns. " \ + "E.g. update_columns(foo: 'bar')" + + ActiveSupport::Deprecation.warn(msg) + update_columns(name => value) end @@ -243,7 +248,7 @@ module ActiveRecord # Saving is not subjected to validation checks. Returns +true+ if the # record could be saved. def increment!(attribute, by = 1) - increment(attribute, by).update_column(attribute, self[attribute]) + increment(attribute, by).update_columns(attribute => self[attribute]) end # Initializes +attribute+ to zero if +nil+ and subtracts the value passed as +by+ (default is 1). @@ -260,7 +265,7 @@ module ActiveRecord # Saving is not subjected to validation checks. Returns +true+ if the # record could be saved. def decrement!(attribute, by = 1) - decrement(attribute, by).update_column(attribute, self[attribute]) + decrement(attribute, by).update_columns(attribute => self[attribute]) end # Assigns to +attribute+ the boolean opposite of <tt>attribute?</tt>. So @@ -277,7 +282,7 @@ module ActiveRecord # Saving is not subjected to validation checks. Returns +true+ if the # record could be saved. def toggle!(attribute) - toggle(attribute).update_column(attribute, self[attribute]) + toggle(attribute).update_columns(attribute => self[attribute]) end # Reloads the attributes of this object from the database. |