aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorTiago Macedo <tmacedo@webreakstuff.com>2008-06-08 17:00:56 +0100
committerJeremy Kemper <jeremy@bitsweat.net>2008-06-08 13:01:55 -0700
commita2f6ded73209eeb9c6843b16c0253bbe56236b29 (patch)
tree475cbf39c3f042dfe67f94168389930a861b4582 /activerecord/lib/active_record
parent138adbf156905f5cc6669ba33dd94802c82514d9 (diff)
downloadrails-a2f6ded73209eeb9c6843b16c0253bbe56236b29.tar.gz
rails-a2f6ded73209eeb9c6843b16c0253bbe56236b29.tar.bz2
rails-a2f6ded73209eeb9c6843b16c0253bbe56236b29.zip
Fix conditions and order on join tables with limited eager loading. [#372 state:resolved]
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index a3d1bbbada..8ddcc24daa 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1638,7 +1638,9 @@ module ActiveRecord
end
def join_for_table_name(table_name)
- @joins.select{|j|j.aliased_table_name == table_name.gsub(/^\"(.*)\"$/){$1} }.first rescue nil
+ join = (@joins.select{|j|j.aliased_table_name == table_name.gsub(/^\"(.*)\"$/){$1} }.first) rescue nil
+ return join unless join.nil?
+ @joins.select{|j|j.is_a?(JoinAssociation) && j.aliased_join_table_name == table_name.gsub(/^\"(.*)\"$/){$1} }.first rescue nil
end
def joins_for_table_name(table_name)