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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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
-------------------------------------
1 Books 0
2 Fiction 1
3 Non-Fiction 1
You might want to assign a book to non-fiction so the book''s
category_id becomes ''3''. For simple category systems, I tend
to use a
select box like this:
Books
Fiction
Non-fiction
As for managing the categories, I tend to have the child categories
listed on my ''Edit Category'' form. From there I can edit and
create
new child categories.
Hope that helps,
Steve
http://www.stephenbartholomew.co.uk
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
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 On Sep 9, 2:05 am, Steve Bartholomew <st...-LWB5c3/XHbdBDgjK7y7TUQ@public.gmane.org> wrote:> 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 > ------------------------------------- > 1 Books 0 > 2 Fiction 1 > 3 Non-Fiction 1 > > You might want to assign a book to non-fiction so the book''s > category_id becomes ''3''. For simple category systems, I tend to use a > select box like this: > > Books > Fiction > Non-fiction > > As for managing the categories, I tend to have the child categories > listed on my ''Edit Category'' form. From there I can edit and create > new child categories. > > Hope that helps, > > Steve > > http://www.stephenbartholomew.co.uk--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---