aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-10-13 12:01:27 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-10-13 12:01:27 -0700
commitc56dc753b400cf73cc8d3284a0ae3a7bb5e72aa1 (patch)
treecc3c2deda68eed2cb34e39b730b37b210d408b24
parentb205ae8a949d47737f9ae6046b164ef64bd88015 (diff)
parent625cd69a8b74a49fe2831983e89536f872c5abe7 (diff)
downloadrails-c56dc753b400cf73cc8d3284a0ae3a7bb5e72aa1.tar.gz
rails-c56dc753b400cf73cc8d3284a0ae3a7bb5e72aa1.tar.bz2
rails-c56dc753b400cf73cc8d3284a0ae3a7bb5e72aa1.zip
Merge pull request #12511 from jetthoughts/informative_raise_message_for_incorrect_association
Make missed association exception message more informative
-rw-r--r--activerecord/CHANGELOG.md6
-rw-r--r--activerecord/lib/active_record/associations/preloader.rb6
2 files changed, 9 insertions, 3 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index c3c4ae7862..658645275d 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,9 @@
+* For missed association exception message
+ which is raised in `ActiveRecord::Associations::Preloader` class
+ added owner record class name in order to simplify to find problem code.
+
+ *Paul Nikitochkin*
+
* `has_and_belongs_to_many` is now transparently implemented in terms of
`has_many :through`. Behavior should remain the same, if not, it is a bug.
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