diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-02-03 04:30:14 -0800 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-02-03 04:30:14 -0800 |
commit | b4f189a162f4280b360dbc2a6635bbff6c6f09bc (patch) | |
tree | 638e165ad8490056f378d1715e4b01b88d1e2be8 /activerecord/lib/active_record/base.rb | |
parent | bf794bb36f3bd06e2e863cd6c6dfb6ceae116af2 (diff) | |
parent | e8357935acde972fe42a1a3e0d8c969e518956ed (diff) | |
download | rails-b4f189a162f4280b360dbc2a6635bbff6c6f09bc.tar.gz rails-b4f189a162f4280b360dbc2a6635bbff6c6f09bc.tar.bz2 rails-b4f189a162f4280b360dbc2a6635bbff6c6f09bc.zip |
Merge pull request #9159 from lexmag/col_defaults-dup-fix
Backport: Duplicate column_defaults properly
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 612114bbce..5a7743b808 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -479,7 +479,8 @@ module ActiveRecord #:nodoc: # # Instantiates a single new object bypassing mass-assignment security # User.new({ :first_name => 'Jamie', :is_admin => true }, :without_protection => true) def initialize(attributes = nil, options = {}) - @attributes = self.class.initialize_attributes(self.class.column_defaults.dup) + defaults = Hash[self.class.column_defaults.map { |k, v| [k, v.duplicable? ? v.dup : v] }] + @attributes = self.class.initialize_attributes(defaults) @association_cache = {} @aggregation_cache = {} @attributes_cache = {} |