aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/reflection.rb2
-rw-r--r--activerecord/test/reflection_test.rb2
2 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index d2c5393b59..aab5444583 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -97,7 +97,7 @@ module ActiveRecord
# Holds all the meta-data about an aggregation as it was specified in the Active Record class.
class AggregateReflection < MacroReflection #:nodoc:
def klass
- @klass ||= Object.const_get(class_name)
+ @klass ||= Object.const_get(options[:class_name] || class_name)
end
private
diff --git a/activerecord/test/reflection_test.rb b/activerecord/test/reflection_test.rb
index a409a5a520..64689595fe 100644
--- a/activerecord/test/reflection_test.rb
+++ b/activerecord/test/reflection_test.rb
@@ -74,6 +74,8 @@ class ReflectionTest < Test::Unit::TestCase
assert_equal reflection_for_address, Customer.reflect_on_aggregation(:address)
assert_equal Address, Customer.reflect_on_aggregation(:address).klass
+
+ assert_equal Money, Customer.reflect_on_aggregation(:balance).klass
end
def test_has_many_reflection