aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-04-06 02:58:32 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-04-06 02:58:32 +0000
commit2fa5bf03dd0105a70402b1abcf0ac3df54140a55 (patch)
treefff773074f9aeb76b20e50e45118a4d4074ff87a
parent26e187516f3a57a432f59dfec3244d1fbc8c58de (diff)
downloadrails-2fa5bf03dd0105a70402b1abcf0ac3df54140a55.tar.gz
rails-2fa5bf03dd0105a70402b1abcf0ac3df54140a55.tar.bz2
rails-2fa5bf03dd0105a70402b1abcf0ac3df54140a55.zip
Reflect on aggregation ignores :class_name option (fixes #4599) [lars pind]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4175 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-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