From 6a0a5f30324571416174430cf41f3355635c3328 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 3 Feb 2013 15:27:42 +0400 Subject: Duplicate column_defaults properly Backport c517602 to fix #6115 Deleted: activerecord/lib/active_record/core.rb Conflicts: activerecord/test/cases/base_test.rb --- activerecord/lib/active_record/base.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') 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 = {} -- cgit v1.2.3