Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$ git diff
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/associa
index 5b34ac9..3e80ec9 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -55,6 +55,8 @@ module ActiveRecord
with_scope(:find => @scope[:find].slice(:conditions, :order)) do
relation = @reflection.klass.send(:construct_finder_arel, options, @reflection.klass.send(:current_scoped_methods))
+ relation = relation.joins(Arel::SqlLiteral.new(@scope[:find][:joins])) if @scope[:find][:joins].present?
+ relation = relation.joins(options[:joins]) if options[:joins].present?
case args.first
when :first, :last
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associa
index da742fa..2d673c6 100644
--- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
@@ -24,7 +24,7 @@ module ActiveRecord
protected
def construct_find_options!(options)
- options[:joins] = Arel::SqlLiteral.new(@scope[:find][:joins])
+ #options[:joins] = Arel::SqlLiteral.new(@scope[:find][:joins])
options[:readonly] = finding_with_ambiguous_select?(options[:select] || @reflection.options[:select])
options[:select] ||= (@reflection.options[:select] || Arel::SqlLiteral.new('*'))
end
(END)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment