Multiple sub categories (parent-child)


#1

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.


#2

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

thanks.


#3

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


#4

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


#5

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.


#6

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.


#7

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