diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-12-23 14:19:08 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-23 15:19:18 -0800 |
commit | fb3a8c51b4028e8d122fdbb783d73d0ed37ca168 (patch) | |
tree | 6c951f1b78715f39223ffcd6f3f5137fd7db3003 /activerecord/lib/active_record/associations.rb | |
parent | 1c07b84df95e932d50376c1d0a13585b2e2ef868 (diff) | |
download | rails-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/associations.rb')
-rw-r--r-- | activerecord/lib/active_record/associations.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 0aea05b348..1056c51a3d 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -20,12 +20,18 @@ module ActiveRecord end end - class HasManyThroughAssociationPolymorphicError < ActiveRecordError #:nodoc: + class HasManyThroughAssociationPolymorphicSourceError < ActiveRecordError #:nodoc: def initialize(owner_class_name, reflection, source_reflection) super("Cannot have a has_many :through association '#{owner_class_name}##{reflection.name}' on the polymorphic object '#{source_reflection.class_name}##{source_reflection.name}'.") end end + class HasManyThroughAssociationPolymorphicThroughError < ActiveRecordError #:nodoc: + def initialize(owner_class_name, reflection) + super("Cannot have a has_many :through association '#{owner_class_name}##{reflection.name}' which goes through the polymorphic association '#{owner_class_name}##{reflection.through_reflection.name}'.") + end + end + class HasManyThroughAssociationPointlessSourceTypeError < ActiveRecordError #:nodoc: def initialize(owner_class_name, reflection, source_reflection) super("Cannot have a has_many :through association '#{owner_class_name}##{reflection.name}' with a :source_type option if the '#{reflection.through_reflection.class_name}##{source_reflection.name}' is not polymorphic. Try removing :source_type on your association.") |