diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-18 03:39:18 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-18 03:39:18 +0000 |
commit | df97ed5e4c986be875248ec1b27d7acfc200ae9c (patch) | |
tree | f7a22b81c151979d16ae36b9783e653f10b90892 /activerecord/lib/active_record/associations | |
parent | 9bd7db4a980652f327e4410b0be0345bee761bf8 (diff) | |
download | rails-df97ed5e4c986be875248ec1b27d7acfc200ae9c.tar.gz rails-df97ed5e4c986be875248ec1b27d7acfc200ae9c.tar.bz2 rails-df97ed5e4c986be875248ec1b27d7acfc200ae9c.zip |
Nicer error message on has_many :through when :through reflection can not be found (closes #4042) [court3nay@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3910 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_through_association.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb index 009ac7c53a..e242b9f7a1 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -61,7 +61,9 @@ module ActiveRecord end def construct_conditions - through_reflection = @owner.class.reflections[@reflection.options[:through]] + unless through_reflection = @owner.class.reflections[@reflection.options[:through]] + raise ActiveRecordError, "Could not find the association '#{@reflection.options[:through]}' in model #{@reflection.klass}" + end if through_reflection.options[:as] conditions = |