Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #12511 from jetthoughts/informative_raise_message_…

…for_incorrect_association

Make missed association exception message more informative
  • Loading branch information...
commit c56dc753b400cf73cc8d3284a0ae3a7bb5e72aa1 2 parents b205ae8 + 625cd69
@rafaelfranca rafaelfranca authored
View
6 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.
View
6 activerecord/lib/active_record/associations/preloader.rb
@@ -153,13 +153,13 @@ def records_by_reflection(association, records)
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
Please sign in to comment.
Something went wrong with that request. Please try again.