Hi,

I think I misunderstood your email subject that you wanted to do multiple
joins from activerecord with a single table, so I quickly pasted the code to
do so :).
Sharagoz's answer looks right.

On Tue, Apr 27, 2010 at 18:12, Ben Woodcroft <[email protected]> wrote:

> Dhruva Sagar wrote:
> > Yes,
> >
> > class Deck < ActiveRecord::Base
> >  has_many :cards
> >  has_many :cool_cards, :through => :cards
> > end
>
> Thanks for the help Dhruva, but doesn't that mean that there is a
> cool_cards foreign key in the cards cards table? I don't quite
> understand how this helps - what query would you run to get decks that
> have aces and kings?
>
> I should also add some details to the schema, in case I wasn't clear.
> ------------------------------------
> class Deck < ActiveRecord::Base
>  has_many :cards
> end
>
> class Card < ActiveRecord::Base
>   belongs_to :deck
>  # has a "name" attribute/column, which is king/ace/jack/etc.
> end
> ------------------------------------
>
> Thanks,
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to