class method
self.add_joins!
Ruby on Rails 2.2.3
Since v2.2.3 Last seen in v2.3.18 PrivateAvailable in: v2.2.3 v2.3.18
Signature
self.add_joins!(sql, joins, scope = :auto)
The optional scope argument is for the current :find scope.
Parameters
-
sqlreq -
joinsreq -
scopeopt = :auto
Source
# File activerecord/lib/active_record/base.rb, line 1721
def add_joins!(sql, joins, scope = :auto)
scope = scope(:find) if :auto == scope
merged_joins = scope && scope[:joins] && joins ? merge_joins(scope[:joins], joins) : (joins || scope && scope[:joins])
case merged_joins
when Symbol, Hash, Array
if array_of_strings?(merged_joins)
sql << merged_joins.join(' ') + " "
else
join_dependency = ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, merged_joins, nil)
sql << " #{join_dependency.join_associations.collect { |assoc| assoc.association_join }.join} "
end
when String
sql << " #{merged_joins} "
end
end
Defined in activerecord/lib/active_record/base.rb line 1721
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Base