diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2013-02-03 15:27:42 +0400 |
---|---|---|
committer | Alan Daud <olancheg@gmail.com> | 2013-02-03 15:27:42 +0400 |
commit | 6a0a5f30324571416174430cf41f3355635c3328 (patch) | |
tree | 5748a3db0e1f3a53faf2290db883a05db435145a /activerecord/lib/active_record | |
parent | bf794bb36f3bd06e2e863cd6c6dfb6ceae116af2 (diff) | |
download | rails-6a0a5f30324571416174430cf41f3355635c3328.tar.gz rails-6a0a5f30324571416174430cf41f3355635c3328.tar.bz2 rails-6a0a5f30324571416174430cf41f3355635c3328.zip |
Duplicate column_defaults properly
Backport c517602 to fix #6115
Deleted:
activerecord/lib/active_record/core.rb
Conflicts:
activerecord/test/cases/base_test.rb
Diffstat (limited to 'activerecord/lib/active_record')
-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 = {} |