diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-07-09 17:14:14 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-07-09 17:14:14 +0000 |
commit | 14762fd229dfdde98bef224f198ff1ade7336b5b (patch) | |
tree | 2b54f8deff3ffcf002fb88152a45c2122c300cdf /activerecord/lib | |
parent | 1d7aa9fe813afb1979dfefd0871d84eb60d92d39 (diff) | |
download | rails-14762fd229dfdde98bef224f198ff1ade7336b5b.tar.gz rails-14762fd229dfdde98bef224f198ff1ade7336b5b.tar.bz2 rails-14762fd229dfdde98bef224f198ff1ade7336b5b.zip |
better error message for missing associations #1631 [courtenay]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1787 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 419187015b..6f49800df6 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -739,13 +739,20 @@ module ActiveRecord end def find_with_associations(options = {}) - reflections = reflect_on_included_associations(options[:include]) + reflections = reflect_on_included_associations(options[:include]) + reflections.each do |r| + raise( + NoMethodError, + "Association was not found; perhaps you misspelled it? You specified :include=>:#{options[:include].join(', :')}" + ) if r.nil? + end + schema_abbreviations = generate_schema_abbreviations(reflections) primary_key_table = generate_primary_key_table(reflections, schema_abbreviations) - rows = select_all_rows(options, schema_abbreviations, reflections) - records, records_in_order = { }, [] - primary_key = primary_key_table[table_name] + rows = select_all_rows(options, schema_abbreviations, reflections) + records, records_in_order = { }, [] + primary_key = primary_key_table[table_name] for row in rows id = row[primary_key] |