Category - Subcategory

Hi there,

I have a Products table. Each product has a category_id and subcategory_id which relate to the categories and subcategories tables respectively.

1) How do I create a view for creating new subcategories? Obviously, upon entering a new subcategory, I would need to select the category to which it should belong.

2) Same problem with entering new products. I have to choose a category from a drop-down list and then a subcategory that relates to that category.

Any help greatly appreciated.

God bless, Paul

Hey,

I personally favor having a 'tree-like' category structure instead of separate categories/subcategories. When you think about it, a 'Category' and a 'SubCategory' are normally the same thing - just one is a parent of the other.

Try looking at 'acts_as_tree' for your categories. In this set up, each category can have a parent_id which tells you which category a sub or 'child' category is in.

For example:

id name parent_id

Hi Steve,

Thanks for the advice. I like the tree idea and your idea for the drop- down menu. Would you have the templates to view so I can see more construction detail?

Much appreciated if so.

God bless, Paul