diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-10-31 11:30:14 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-10-31 11:30:14 -0600 |
commit | 9b9f0197b7e645ae5b05a5581ba82f32f0971183 (patch) | |
tree | 941324fe8afdb5d4ae925cd4b4b1ebb6ee334a80 | |
parent | 53ec0bc0551c696add0a5ffff506fc9e83065bc0 (diff) | |
download | rails-9b9f0197b7e645ae5b05a5581ba82f32f0971183.tar.gz rails-9b9f0197b7e645ae5b05a5581ba82f32f0971183.tar.bz2 rails-9b9f0197b7e645ae5b05a5581ba82f32f0971183.zip |
Rename `default_attributes` to `_default_attributes`
It is internal use only. This is to avoid conflicting with users' method
names. Fixes #17458
-rw-r--r-- | activerecord/lib/active_record/core.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/model_schema.rb | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 9ab27bbac5..a0382f99e6 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -266,7 +266,7 @@ module ActiveRecord # # Instantiates a single new object # User.new(first_name: 'Jamie') def initialize(attributes = nil, options = {}) - @attributes = self.class.default_attributes.dup + @attributes = self.class._default_attributes.dup init_internals initialize_internals_callback diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index 48e82d28d9..31ff08a89d 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -247,10 +247,10 @@ module ActiveRecord # Returns a hash where the keys are column names and the values are # default values when instantiating the AR object for this table. def column_defaults - default_attributes.to_hash + _default_attributes.to_hash end - def default_attributes # :nodoc: + def _default_attributes # :nodoc: @default_attributes ||= attributes_builder.build_from_database( columns_hash.transform_values(&:default)) end |