aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMarcelo Giorgi <marklazz.uy@gmail.com>2010-09-08 21:55:05 -0300
committerMikel Lindsaar <raasdnil@gmail.com>2010-09-10 21:14:07 +1000
commita513f8f8bb3c4fff88ab27a8f2c591d9d7c27cf9 (patch)
treee9fcbf3706742485daa48c2937dc1087d40ea538 /activerecord
parent1c283765b603ffe57ebe924564b9e273f52bda14 (diff)
downloadrails-a513f8f8bb3c4fff88ab27a8f2c591d9d7c27cf9.tar.gz
rails-a513f8f8bb3c4fff88ab27a8f2c591d9d7c27cf9.tar.bz2
rails-a513f8f8bb3c4fff88ab27a8f2c591d9d7c27cf9.zip
intersection between a relation and an array works in both directions
Signed-off-by: Mikel Lindsaar <raasdnil@gmail.com>
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation/spawn_methods.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index f039645255..9ecdb99bee 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -5,6 +5,7 @@ module ActiveRecord
def merge(r)
merged_relation = clone
return merged_relation unless r
+ return to_a & r if r.is_a?(Array)
Relation::ASSOCIATION_METHODS.each do |method|
value = r.send(:"#{method}_values")