jeudi 2 avril 2015

Query in Rails to fetch from database

I have a table Info(:name, :friend_id) and another table Friends(:id, :network). The attribute :network can be Facebook/Gmail/Linkedin. I want to count all my friends from all services like count of friends from FB, Gmail and Linkedin. I have a friends_list



friends_list = Info.where(:name => my_name)


I don't want to iterate over friends_list and find for each friend_id the normal way. Is there a single line query which can give me the count of all friends from Facebook?


Aucun commentaire:

Enregistrer un commentaire