From 2d9e5a26a10e5f83f9b3ac465bd45b2e15a0bc2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 24 Jul 2012 20:20:03 -0300 Subject: Deprecate update_column in favor of update_columns. Closes #1190 --- .../lib/active_record/associations/has_one_association.rb | 2 +- activerecord/lib/active_record/persistence.rb | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'activerecord/lib') 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 attribute?. 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. -- cgit v1.2.3