From 625cd69a8b74a49fe2831983e89536f872c5abe7 Mon Sep 17 00:00:00 2001 From: Paul Nikitochkin Date: Sat, 12 Oct 2013 16:39:09 +0300 Subject: Make missed association exception message more informative Add target class name, which should have missed association on preload, into exception message to simplify detecting problem part. --- activerecord/lib/active_record/associations/preloader.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record/associations/preloader.rb') diff --git a/activerecord/lib/active_record/associations/preloader.rb b/activerecord/lib/active_record/associations/preloader.rb index 713ff80d47..2393667ac8 100644 --- a/activerecord/lib/active_record/associations/preloader.rb +++ b/activerecord/lib/active_record/associations/preloader.rb @@ -153,13 +153,13 @@ module ActiveRecord records.group_by do |record| reflection = record.class.reflect_on_association(association) - reflection || raise_config_error(association) + reflection || raise_config_error(record, association) end end - def raise_config_error(association) + def raise_config_error(record, association) raise ActiveRecord::ConfigurationError, - "Association named '#{association}' was not found; " \ + "Association named '#{association}' was not found on #{record.class.name}; " \ "perhaps you misspelled it?" end -- cgit v1.2.3