aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/model_schema.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-10-31 16:06:14 -0600
committerSean Griffin <sean@thoughtbot.com>2014-10-31 16:06:14 -0600
commit4010a9ddc6d91c40cc87a30c03e8dfd9ae214dbb (patch)
treeb8a7aef2c520d536f84065031a43655115f43b3e /activerecord/lib/active_record/model_schema.rb
parent61bacd6ef9c302238f3b8d9e6b432ee2090f6b78 (diff)
downloadrails-4010a9ddc6d91c40cc87a30c03e8dfd9ae214dbb.tar.gz
rails-4010a9ddc6d91c40cc87a30c03e8dfd9ae214dbb.tar.bz2
rails-4010a9ddc6d91c40cc87a30c03e8dfd9ae214dbb.zip
Don't modify the columns hash to set defaults from the attributes API
Nothing is directly using the columns for the default values anymore. This step helps us get closer not not mutating the columns hash.
Diffstat (limited to 'activerecord/lib/active_record/model_schema.rb')
-rw-r--r--activerecord/lib/active_record/model_schema.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb
index 31ff08a89d..a444aac23c 100644
--- a/activerecord/lib/active_record/model_schema.rb
+++ b/activerecord/lib/active_record/model_schema.rb
@@ -252,7 +252,7 @@ module ActiveRecord
def _default_attributes # :nodoc:
@default_attributes ||= attributes_builder.build_from_database(
- columns_hash.transform_values(&:default))
+ raw_default_values)
end
# Returns an array of column names as strings.
@@ -331,6 +331,10 @@ module ActiveRecord
base.table_name
end
end
+
+ def raw_default_values
+ columns_hash.transform_values(&:default)
+ end
end
end
end