Dhruva Sagar wrote: > Hi Ben, > > m_id = Materials.first(:conditions => "name == 'cardboard'") > > Deck.all(:joins => 'inner join cards on cards.deck_id = cards.id', > :conditions => ["(cards.name = 'Ace' OR cards.name = 'King') AND > cards.material_id=?", m_id]) > > How about that ?
I don't think that would work since it would get all decks that have kings OR aces, where I want both to be there. But apart from that in my real-world example there is actually 30,000 or so different materials that are acceptable, so loading all of those out of the database into ruby-land would take longer than iterating through each deck individually using ------- Deck.all.select{|d| Card.ace.cardboard.count > 0 and Card.king.cardboard.count > 0 } ------- where ace and cardboard are simple named_scopes using joins and conditions. Thanks for the continued assistance, ben -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.