ok, here''s my dilemna...i have a site that has a list of item combinations (aka compounds) for a computer game. i''m having a hard time coming up with a good way to search a compounds result and the items that are contained within the compound. the formulas are setup like: COMPOUND = COMPOUND_MATERIAL + COMPOUND_MATERIAL...(compound has up to 5 compound_materials) to get a better idea of what i mean check this page from the site http://wlodb.com/compounds my table setup is: ITEMS (which can be a compound result or compound component) -ID -name -description -... COMPOUNDS (has_many compound_materials) -ID -item_id -... COMPOUND_MATERIALS (belongs_to item, compound -ID -item_id -compound_id i guess my first question would be what is the best way that i can search on ITEM table values like names with the least amount of queries. i thought about doing joins from compound and compound_materials to items but i''m sure if it''s possible joining to the same table twice. at the moment i am doing it this way: @compounds = Compound.search(...) @compound_materials = CompoundMaterial.search(...) for compound_material in @compound_materials compound = Compound.find(:all, :conditions => [ "compounds.id ?", compound_material.compound_id]) @compounds += compound if not compound.blank? end @compounds.uniq! @compounds.sort! {...} pretty ugly huh? hope someone can help since i have been trying to come up with a solution for a few hours now. -- 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 -~----------~----~----~----~------~----~------~--~---