# Multiple sub categories (parent-child)

**URL:** <https://www.ruby-forum.com/t/multiple-sub-categories-parent-child/80301>\
**Category:** Rails\
**Created:** [March 13, 2006, 12:54pm UTC](https://www.ruby-forum.com/t/multiple-sub-categories-parent-child/80301 "2006-03-13T12:54:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mickey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ccd318/32.png) [@mickey](https://www.ruby-forum.com/u/mickey)\
**Post date:** [March 13, 2006, 12:54pm UTC](https://www.ruby-forum.com/t/multiple-sub-categories-parent-child/80301/1 "2006-03-13T12:54:04Z")

</div>

cookbook app has one category \> multiple recipes

id like to have multiple sub categories, unlimietd levels.

please show some code, as i am very new to ruby and rails.

thanks.

---

<div class="post-metadata">

**Author:** ![mickey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ccd318/32.png) [@mickey](https://www.ruby-forum.com/u/mickey)\
**Post date:** [March 14, 2006, 8:56am UTC](https://www.ruby-forum.com/t/multiple-sub-categories-parent-child/80301/2 "2006-03-14T08:56:20Z")

</div>

no one could help me here? wanted to see if there’s a quickie way.

thanks.

---

<div class="post-metadata">

**Author:** ![mickey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ccd318/32.png) [@mickey](https://www.ruby-forum.com/u/mickey)\
**Post date:** [March 14, 2006, 9:57am UTC](https://www.ruby-forum.com/t/multiple-sub-categories-parent-child/80301/3 "2006-03-14T09:57:05Z")

</div>

David Ang wrote:

> no one could help me here? wanted to see if there’s a quickie way.  
> The quick way is to have a look at acts\_as\_tree for the categories. In  
> brief, you give your categories table a parent\_id and tell the model  
> that it acts\_as\_tree, and everything should fall into place. You’ll  
> then need to figure out how you want to specify which category is the  
> parent of a new one on creation.

HTH

---

<div class="post-metadata">

**Author:** ![mickey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ccd318/32.png) [@mickey](https://www.ruby-forum.com/u/mickey)\
**Post date:** [March 14, 2006, 10:31am UTC](https://www.ruby-forum.com/t/multiple-sub-categories-parent-child/80301/4 "2006-03-14T10:31:53Z")

</div>

hi alex.

thanks very much. good thing ruby has these features.

Alex Y. wrote:

> David Ang wrote:
> 
> > no one could help me here? wanted to see if there’s a quickie way.  
> > The quick way is to have a look at acts\_as\_tree for the categories. In  
> > brief, you give your categories table a parent\_id and tell the model  
> > that it acts\_as\_tree, and everything should fall into place. You’ll  
> > then need to figure out how you want to specify which category is the  
> > parent of a new one on creation.
> 
> HTH

---

<div class="post-metadata">

**Author:** ![mickey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ccd318/32.png) [@mickey](https://www.ruby-forum.com/u/mickey)\
**Post date:** [March 14, 2006, 2:24pm UTC](https://www.ruby-forum.com/t/multiple-sub-categories-parent-child/80301/5 "2006-03-14T14:24:46Z")

</div>

David Ang wrote:

> okay its hard. its not as easy as i thought
> 
> does the acts as list has a scaffold code? or do i need to create my own  
> “category page”?
> 
> some code really would be very helpful.  
> I haven’t tried it yet, but the Ajax scaffolding might be useful here,  
> as might the Scaffolding Extensions… Google is your friend.

---

<div class="post-metadata">

**Author:** ![mickey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ccd318/32.png) [@mickey](https://www.ruby-forum.com/u/mickey)\
**Post date:** [March 14, 2006, 2:35pm UTC](https://www.ruby-forum.com/t/multiple-sub-categories-parent-child/80301/6 "2006-03-14T14:35:27Z")

</div>

hi alex

i appreciate you helping me out

the ajax scaffold is pretty nice [http://ajaxscaffold.height1percent.com/](http://ajaxscaffold.height1percent.com/)

but alas, both stuff you mentioned, doesn’t incorporate acts\_as\_tree on  
their codes.

Alex Y. wrote:

> David Ang wrote:
> 
> > okay its hard. its not as easy as i thought
> > 
> > does the acts as list has a scaffold code? or do i need to create my own  
> > “category page”?
> > 
> > some code really would be very helpful.  
> > I haven’t tried it yet, but the Ajax scaffolding might be useful here,  
> > as might the Scaffolding Extensions… Google is your friend.

---

<div class="post-metadata">

**Author:** ![mickey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ccd318/32.png) [@mickey](https://www.ruby-forum.com/u/mickey)\
**Post date:** [March 14, 2006, 1:23pm UTC](https://www.ruby-forum.com/t/multiple-sub-categories-parent-child/80301/7 "2006-03-14T13:23:10Z")

</div>

okay its hard. its not as easy as i thought

does the acts as list has a scaffold code? or do i need to create my own  
“category page”?

some code really would be very helpful.

Alex Y. wrote:

> David Ang wrote:
> 
> > no one could help me here? wanted to see if there’s a quickie way.  
> > The quick way is to have a look at acts\_as\_tree for the categories. In  
> > brief, you give your categories table a parent\_id and tell the model  
> > that it acts\_as\_tree, and everything should fall into place. You’ll  
> > then need to figure out how you want to specify which category is the  
> > parent of a new one on creation.
> 
> HTH
