From 1e554a6011c3603b509ac0d83bf81c866053bb49 Mon Sep 17 00:00:00 2001 From: Sebastian Korfmann Date: Sat, 8 Sep 2012 09:09:48 +1000 Subject: Improve exception message for HasManyThroughAssociationPolymorphicSourceError Exception message was misleading, as it is possible to have a polymorphic 'has_many :through' join model. --- activerecord/lib/active_record/associations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index d6b8552e6e..60b7118d7e 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -17,7 +17,7 @@ module ActiveRecord 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}'.") + super("Cannot have a has_many :through association '#{owner_class_name}##{reflection.name}' on the polymorphic object '#{source_reflection.class_name}##{source_reflection.name}' without 'source_type'. Try adding 'source_type: \"#{reflection.name.to_s.classify}\"' to 'has_many :through' definition.") end end -- cgit v1.2.3