aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-03-13 18:41:42 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-03-13 18:41:42 +0000
commit2c6e616b90483681ccaff7e04d47b88470a309b0 (patch)
treeb81443a1e3d81c869ab49a3beff7d78eb4c1175a /activerecord/lib/active_record
parent58c30f61351dae43900c3b6cb5dd3622f12ecee0 (diff)
downloadrails-2c6e616b90483681ccaff7e04d47b88470a309b0.tar.gz
rails-2c6e616b90483681ccaff7e04d47b88470a309b0.tar.bz2
rails-2c6e616b90483681ccaff7e04d47b88470a309b0.zip
Fixed that scoped joins would not always be respected (closes #6821) [Theory/Danger]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9022 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-xactiverecord/lib/active_record/base.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index a30036f561..7de760b28e 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1478,13 +1478,14 @@ module ActiveRecord #:nodoc:
# The optional scope argument is for the current :find scope.
def add_joins!(sql, options, scope = :auto)
scope = scope(:find) if :auto == scope
- join = (scope && scope[:joins]) || options[:joins]
- case join
- when Symbol, Hash, Array
- join_dependency = ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, join, nil)
- sql << " #{join_dependency.join_associations.collect { |assoc| assoc.association_join }.join} "
- else
- sql << " #{join} "
+ [(scope && scope[:joins]), options[:joins]].each do |join|
+ case join
+ when Symbol, Hash, Array
+ join_dependency = ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, join, nil)
+ sql << " #{join_dependency.join_associations.collect { |assoc| assoc.association_join }.join} "
+ else
+ sql << " #{join} "
+ end
end
end