ruby on rails - Pulling from two arrays a non-matching object -
i have 2 arrays. if object in 1 array has no matching email attribute in other, want build array out of objects..
my attempts @ attacking dragon :
cardreferral.all.map(&:email) - cardsignup.all.map(&:email)
that need! unfortunately, supplies email in array. , want whole object.
simplified example:
a = [:x, :y, :z] b = [:a, :y, :b] a.select { |e| ! b.include? e } => [:x, :z]
so guess in case goes like:
cardreferral.all.select { |e| ! cardsignup.all.include? e.email }
or, incorporating feedback :-) ...
t = cardsignup.all cardreferral.all.reject { |e| t.include? e.email }
Comments
Post a Comment