I have 2 models: class Core < ActiveRecord::Base has_many :votes has_many :messages end class Vote < ActiveRecord::Base belongs_to:core end class Message < ActiveRecord::Base belongs_to:core end In php for view the last cores names with number of messages and sum of votes i do so: mysql_query("SELECT name,votes_join.total_votes,messages_join.number_messages FROM core LEFT JOIN (SELECT sum(vote),core_id FROM votes GROUP BY core_id) as votes_join on votes_join.core_id=core.id LEFT JOIN (SELECT count(*) as number_messages,core_id FROM messages GROUP BY core_id) as messages_join on messages_join.core_id=core.id") Is possibile di it with find method of models?? How? Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---