Hi I have 3 tables as 1) user_groups id | contact_id | group_id | group_user_type_id 2) contact id | name_first | name_last | 3)contact_email_addresses contact_id | contact_email_address_type_id | emailaddress Now I have group_id sa for example 68 What I want is from contact_email_addresses table get all the emailaddress with contact_email_address_type_id=2 for the contacts with this group_id under the condition in the user_groups table group_user_type_id=2 How can I do this? hanks in advance Sijo -- 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 -~----------~----~----~----~------~----~------~--~---
ContactEmailAddresses.find( :all, :conditions => ''contact_email_address_type_id = 2 and group_user_type_id = 2'' :include => ''user_groups'' ) Something to that effect should work.... however it depends how you have your relationships setup... this would work too... contact_type = ContactEmailAddressType.find(2) contact_type.contact_email_addresses.find(:all, :coditions => ''group_user_type_id = 2'', :include => ''user_groups'' ) On Jun 6, 4:53 am, Sijo Kg <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi > I have 3 tables as > 1) user_groups > id | contact_id | group_id | group_user_type_id > 2) contact > id | name_first | name_last | > 3)contact_email_addresses > contact_id | contact_email_address_type_id | emailaddress > > Now I have group_id sa for example 68 > What I want is from contact_email_addresses table get all the > emailaddress with contact_email_address_type_id=2 for the contacts with > this group_id under the condition in the user_groups table > group_user_type_id=2 > How can I do this? > > hanks in advance > Sijo > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi thanks for your reply Sijo -- 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 -~----------~----~----~----~------~----~------~--~---