For some reason I can't figure this out. But basically I want to compare to models and see if they have any matching emails. Here's my attempt, but this doesn't for some reason work at all.
>> CardReferral.all.select{|cf|cf.email == CardSignup.all.collect{|cs|cs.email}}
Where I can somehow return the object..
CardReferral.all.map(&:email) & CardSignup.all.map(&:email)
from the rdoc
array & other_array Set Intersection—Returns a new array containing elements common to the two arrays, with no duplicates.
[ 1, 1, 3, 5 ] & [ 1, 2, 3 ] #=> [ 1, 3 ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With