Hi,
I am using the 'contacts' gem in rails to retrieve a users contacts from their mail application. It returns the contacts like so:
["person name", "[email protected]"], ["person name", "[email protected]"], ["person name", "[email protected]"] etc...
I want to compare this list to the Users already signed up for my site
Users.find(:all) returns:
[#<User id: 11, login: "examplelogin", email: "[email protected]">, #<User id: 12, login: "examplelogin", email: "[email protected]">, etc... ]
What is the best way to go about comparing the gmail contact emails to the User emails and displaying only the ones that are a match?
I was thinking something like:
@contacts = Contacts::Gmail[params[:from]].new(params[:login], params[:password]).contacts
@contacts.each do |c|
@email = c[1]
@user = Users.find_by_email(@email)
end
Which would presumably only return the users where there was a match. I feel like there must be a better way to go about this that I am not considering. Any suggestions?