Hi all,
I sat down to rework one of my first rails apps which was a very,
very simple store. The organisation of the products in the store was
rather flat:
class Category < AR:B
has_many :products
end
class Product < AR:B
belongs_to :category
end
I want to do it with arbitrary category nesting this time–a category
can have a subcategory, this on the other hand can have other
subcategories and so on. Only categories that have no other
subcategories can hold products. So far, so good:
class Category < AR:B
acts_as_tree
has_many :products
end
class Product < AR:B
belongs_to :category
end
But how do I prevent users from entering products in categories that
have subcategories? Also, how do I present the user with an interface
for selecting the parent category in the new-product form? Nested
select elements perhaps (one select with all the ‘root’ categories,
selecting a root category triggers the appearance of another select
element with its subcategories and so on until the last selected
category has no more children)?
Many thanks in advance for all pointers!
Nickolay