Forum: Ruby on Rails multiple sub categories (parent-child)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
David A. (Guest)
on 2006-03-13 13:54
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.
David A. (Guest)
on 2006-03-14 09:56
no one could help me here? wanted to see if there's a quickie way.

thanks.
Alex Y. (Guest)
on 2006-03-14 10:57
(Received via mailing list)
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
David A. (Guest)
on 2006-03-14 11:31
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
David A. (Guest)
on 2006-03-14 14:23
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
Alex Y. (Guest)
on 2006-03-14 15:24
(Received via mailing list)
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.
David A. (Guest)
on 2006-03-14 15:35
hi alex

i appreciate you helping me out

the ajax scaffold is pretty nice 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.
This topic is locked and can not be replied to.