aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/reflection.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-12-23 14:19:08 +0000
committerAaron Patterson <aaron.patterson@gmail.com>2010-12-23 15:19:18 -0800
commitfb3a8c51b4028e8d122fdbb783d73d0ed37ca168 (patch)
tree6c951f1b78715f39223ffcd6f3f5137fd7db3003 /activerecord/lib/active_record/reflection.rb
parent1c07b84df95e932d50376c1d0a13585b2e2ef868 (diff)
downloadrails-fb3a8c51b4028e8d122fdbb783d73d0ed37ca168.tar.gz
rails-fb3a8c51b4028e8d122fdbb783d73d0ed37ca168.tar.bz2
rails-fb3a8c51b4028e8d122fdbb783d73d0ed37ca168.zip
Raise an error for associations which try to go :through a polymorphic association [#6212 state:resolved]
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-rw-r--r--activerecord/lib/active_record/reflection.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 87a842bc6b..0310e7050d 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -375,6 +375,10 @@ module ActiveRecord
raise HasManyThroughAssociationNotFoundError.new(active_record.name, self)
end
+ if through_reflection.options[:polymorphic]
+ raise HasManyThroughAssociationPolymorphicThroughError.new(active_record.name, self)
+ end
+
if source_reflection.nil?
raise HasManyThroughSourceAssociationNotFoundError.new(self)
end
@@ -384,7 +388,7 @@ module ActiveRecord
end
if source_reflection.options[:polymorphic] && options[:source_type].nil?
- raise HasManyThroughAssociationPolymorphicError.new(active_record.name, self, source_reflection)
+ raise HasManyThroughAssociationPolymorphicSourceError.new(active_record.name, self, source_reflection)
end
unless [:belongs_to, :has_many, :has_one].include?(source_reflection.macro) && source_reflection.options[:through].nil?