diff options
-rw-r--r-- | activerecord/lib/active_record/aggregations.rb | 7 | ||||
-rw-r--r-- | activerecord/test/models/customer.rb | 1 |
2 files changed, 3 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb index 5de10a8dd6..f0b549e5ad 100644 --- a/activerecord/lib/active_record/aggregations.rb +++ b/activerecord/lib/active_record/aggregations.rb @@ -242,10 +242,9 @@ module ActiveRecord def writer_method(name, class_name, mapping, allow_nil, converter) define_method("#{name}=") do |part| - unless part.is_a?(class_name.constantize) || converter.nil? || part.nil? - part = converter.respond_to?(:call) ? - converter.call(part) : - class_name.constantize.send(converter, part) + klass = class_name.constantize + unless part.is_a?(klass) || converter.nil? || part.nil? + part = converter.respond_to?(:call) ? converter.call(part) : klass.send(converter, part) end if part.nil? && allow_nil diff --git a/activerecord/test/models/customer.rb b/activerecord/test/models/customer.rb index 807f25b687..7e8e82542f 100644 --- a/activerecord/test/models/customer.rb +++ b/activerecord/test/models/customer.rb @@ -1,5 +1,4 @@ class Customer < ActiveRecord::Base - cattr_accessor :gps_conversion_was_run composed_of :address, :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ], :allow_nil => true |