File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
lib/active_record/relation Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ def spawn #:nodoc:
1212
1313 # Merges in the conditions from <tt>other</tt>, if <tt>other</tt> is an ActiveRecord::Relation.
1414 # Returns an array representing the intersection of the resulting records with <tt>other</tt>, if <tt>other</tt> is an array.
15+ #
1516 # Post.where(published: true).joins(:comments).merge( Comment.where(spam: false) )
1617 # # Performs a single join query with both where conditions.
1718 #
@@ -37,11 +38,12 @@ def merge(other)
3738 end
3839
3940 def merge! ( other ) # :nodoc:
40- if !other . is_a? ( Relation ) && other . respond_to? ( :to_proc )
41+ if other . is_a? ( Hash )
42+ Relation ::HashMerger . new ( self , other ) . merge
43+ elsif other . respond_to? ( :to_proc )
4144 instance_exec ( &other )
4245 else
43- klass = other . is_a? ( Hash ) ? Relation ::HashMerger : Relation ::Merger
44- klass . new ( self , other ) . merge
46+ Relation ::Merger . new ( self , other ) . merge
4547 end
4648 end
4749
Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ def self.table_name
2424 def self . sanitize_sql_for_order ( sql )
2525 sql
2626 end
27+
28+ def self . arel_table
29+ Post . arel_table
30+ end
2731 end
2832
2933 def test_construction
You can’t perform that action at this time.
0 commit comments