How to find matches in two arrays in IRB?

For some reason I can't figure it out. But basically I want to compare with the models and see if they have the appropriate letters. Here is my attempt, but it in no way works at all.

>> CardReferral.all.select{|cf|cf.email == CardSignup.all.collect{|cs|cs.email}} 

Where can I somehow return the object.

+4
source share
1 answer
 CardReferral.all.map(&:email) & CardSignup.all.map(&:email) 

from rdoc

array and other_array Set Intersection - returns a new array containing elements common to two arrays, without duplicates.

 [ 1, 1, 3, 5 ] & [ 1, 2, 3 ] #=> [ 1, 3 ] 
+16
source

All Articles