you should then try : Deck.all(:joins => 'inner join cards c1 on c1.deck_id=d.id inner join cards c2 on c2.deck_id=d.id', :conditions => ["c1.rank = 'Ace' AND c2.rank = 'King'])
Forget the many, through thing that was a misunderstanding. On Tue, Apr 27, 2010 at 19:14, Ben Woodcroft <li...@ruby-forum.com> wrote: > Dhruva Sagar wrote: > > Hi, > > > > Can't your sql be : > > > > select * from decks d > > inner join cards c1 on c1.deck_id=d.id > > where > > c1.rank = 'Ace' and > > c1.rank = 'King'; > > Unfortunately I don't think so. c1 cannot be both an ace and a king at > the same time. I just tested your code on a rails setup with a has_many > and belongs_to and it didn't work. > -- > 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<rubyonrails-talk%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- Thanks & Regards, Dhruva Sagar. -- 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.