Topic: Most rails-friendly and clean way to represent product bundles?
I need to design a DB which should hopefully be relatively straightforward but I'm a bit confused as to how to do it 'the rails way', so to speak. The site sells 'products'. Here are the relationships and rules that I need to enforce:
1) Each product has a product code, name, description, zero or more images, zero or more PDF files, price, weight, etc.
2) Some products are actually collections of other individual products, but otherwise have the same attributes as a product, such as price, images etc and need to be displayed and behave like any other individual product - think 'bundle of products'.
3) Each product can exist in one or more product categories.
4) Product categories can be any number of levels deep and products can exist at any level.
I have so far thought I would start with a design something like this:
images_products (many to many table linking products with images)
pdfs_products (many to many table linking products with pdfs)
categories (self-referencing table to create category hierarchy)
categories_products (many to many to allow products to exist anywhere in categories)
Assuming this isn't wrong, how do I best achieve rule #2 above? Do I just need to create a table to join products to itself and how do I model the relationship in rails?