Permalink
Browse files

Use deep_dup in aciverecord default columns assignment

  • Loading branch information...
1 parent 98553a5 commit 93742701b5e1e55599a89c536dd343885086b2a0 @drogus drogus committed May 6, 2012
Showing with 2 additions and 4 deletions.
  1. +2 −4 activerecord/lib/active_record/core.rb
@@ -1,6 +1,6 @@
require 'active_support/concern'
require 'active_support/core_ext/hash/indifferent_access'
-require 'active_support/core_ext/object/duplicable'
+require 'active_support/core_ext/object/deep_dup'
require 'thread'
module ActiveRecord
@@ -166,9 +166,7 @@ def relation #: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 = {})
- # TODO: use deep_dup after fixing it to also dup values
- defaults = Hash[self.class.column_defaults.map { |k, v| [k, v.duplicable? ? v.dup : v] }]
- @attributes = self.class.initialize_attributes(defaults)
+ @attributes = self.class.initialize_attributes(self.class.column_defaults.deep_dup)
@columns_hash = self.class.column_types.dup
init_internals

0 comments on commit 9374270

Please sign in to comment.