aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-07-30 10:15:26 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-07-30 10:16:28 -0300
commit2f930df518077bb2a00ab6d6a6cf579f0d88e250 (patch)
tree217db866b94f113b5e4ed4f6eed1eb76b1f2571e /activerecord/lib
parentcc712f2072e2bfd16db83239dd163eb3a488c45e (diff)
downloadrails-2f930df518077bb2a00ab6d6a6cf579f0d88e250.tar.gz
rails-2f930df518077bb2a00ab6d6a6cf579f0d88e250.tar.bz2
rails-2f930df518077bb2a00ab6d6a6cf579f0d88e250.zip
Revert "Add update_columns and the suggestion of using update_columns
instead of update_column" This reverts commit 9fa06c3d9811113259cb6e00a3a8454b3974add7. This reverts commit 17a64de4980683da3ca3c185205013a29a8cf88d. This reverts commit def9c85ffbdcf63e6c412b6bd4abafaa32ccdb5c, reversing changes made to 6b7d26cf3c061907aedc44f7f36776c9b36950fd. Reason: This was supposed to be released with 3.2.7 before the suggestion to use update_column. Since it was not release now is not good to suggest to use another method because it will confusing the people.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/persistence.rb19
1 files changed, 1 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index d4c9e4f6cf..c9e3fc5b05 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -179,7 +179,7 @@ module ActiveRecord
#
def update_attribute(name, value)
name = name.to_s
- ActiveSupport::Deprecation.warn("update_attribute is deprecated and will be removed in Rails 4. If you want to skip mass-assignment protection, callbacks, and modifying updated_at, use update_columns. If you do want those things, use update_attributes.")
+ ActiveSupport::Deprecation.warn("update_attribute is deprecated and will be removed in Rails 4. If you want to skip mass-assignment protection, callbacks, and modifying updated_at, use update_column. If you do want those things, use update_attributes.")
raise ActiveRecordError, "#{name} is marked as readonly" if self.class.readonly_attributes.include?(name)
send("#{name}=", value)
save(:validate => false)
@@ -229,23 +229,6 @@ module ActiveRecord
end
end
- # Updates the attributes from the passed-in hash, without calling save.
- #
- # * Validation is skipped.
- # * Callbacks are skipped.
- # * updated_at/updated_on column is not updated if that column is available.
- #
- # Raises an +ActiveRecordError+ when called on new objects, or when at least
- # one of the attributes is marked as readonly.
- def update_columns(attributes)
- raise ActiveRecordError, "can not update on a new record object" unless persisted?
- attributes.each_key {|key| raise ActiveRecordError, "#{key.to_s} is marked as readonly" if self.class.readonly_attributes.include?(key.to_s) }
- attributes.each do |k,v|
- raw_write_attribute(k,v)
- end
- self.class.where(self.class.primary_key => id).update_all(attributes) == 1
- end
-
# Initializes +attribute+ to zero if +nil+ and adds the value passed as +by+ (default is 1).
# The increment is performed directly on the underlying attribute, no setter is invoked.
# Only makes sense for number-based attributes. Returns +self+.