aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-09-21 16:06:58 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-09-21 16:10:29 -0300
commitf7b294fcea8cad72231f13e9226cc18cda1cf43f (patch)
tree490b2a164483c0a4419fe67688136dd8c881d1d2 /activerecord
parenta73fd2d3a240bcdcd21deaaec3ca52e5f0ccb3c5 (diff)
downloadrails-f7b294fcea8cad72231f13e9226cc18cda1cf43f.tar.gz
rails-f7b294fcea8cad72231f13e9226cc18cda1cf43f.tar.bz2
rails-f7b294fcea8cad72231f13e9226cc18cda1cf43f.zip
Add back options argument in the ActiveRecord::Base.initialize method
This will make easier to hook protected_attributes gem in our code without making that gem fragile to change in Rails code base. Closes #12243
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/core.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index 5e6fee52f7..7a1069fead 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -163,7 +163,7 @@ module ActiveRecord
# ==== Example:
# # Instantiates a single new object
# User.new(first_name: 'Jamie')
- def initialize(attributes = nil)
+ def initialize(attributes = nil, options = {})
defaults = self.class.column_defaults.dup
defaults.each { |k, v| defaults[k] = v.dup if v.duplicable? }
@@ -176,7 +176,9 @@ module ActiveRecord
ensure_proper_type
populate_with_current_scope_attributes
- assign_attributes(attributes) if attributes
+ # +options+ argument is only needed to make protected_attributes gem easier to hook.
+ # Remove it when we drop support to this gem.
+ init_attributes(attributes, options) if attributes
yield self if block_given?
run_callbacks :initialize unless _initialize_callbacks.empty?
@@ -432,5 +434,11 @@ module ActiveRecord
@changed_attributes[attr] = orig_value if _field_changed?(attr, orig_value, @attributes[attr])
end
end
+
+ # This method is needed to make protected_attributes gem easier to hook.
+ # Remove it when we drop support to this gem.
+ def init_attributes(attributes, options)
+ assign_attributes(attributes)
+ end
end
end