recreant wrote:> I have two models that are playing nicely together. The first is the
> Category model that uses acts_as_tree to create a hierarchy of
> categories based on parent_id. Example:
>
> Category 1
> Sub 1
> Sub 2
> Subsub 1
> Subsubsub 1
> Subsub 2
> Sub 3
> Category 2
> Category 3
>
> Etc...
>
> The second is a Listings model that has a many-to-many relationship to
> the Categories model using has_many :through
>
> So here''s my question: How would I go about finding all of the
> listings in "Sub 2" AND below?
>
> Doing a find for the listings that belong to Sub 2 is obviously very
> easy, but what about including subsub 1, subsubsub1, and subsub 2 and
> returning all tof the results in one instance object (like
> @listings)?
>
> Any general idea of how to go about this would be helpful. I''m
pretty
> new at this so I hope i''m clear enough in my explanation. Thanks!
You should add nested-set capability to the model:
http://github.com/chris/better_nested_set/tree/master
http://github.com/collectiveidea/awesome_nested_set/tree/master
--
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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
-~----------~----~----~----~------~----~------~--~---