Hi,
I’m developing an application which has to manage many types of
products.
But I can’t think what the best approach in rails is on how to implement
them. Here is a selection of some of the products (with some data types)
that the software will have to manage:
Speaker
Make - String
Model - String
Wattage - Integer
Price - Decimal
Light
Make - String
Model - String
Wattage - Integer
Price - Decimal
Microphone
Make - String
Model - String
Use - Choice of: Instrumental, Vocal, Versatile
Price - Decimal
Cable
Length - Decimal
Connector 1 - String
Connector 2 - String
Price - Decimal
Stand
Type - Choice of: Microphone, Speaker
Height - Decimal
Boom - Boolean
Price - Decimal
Ways I have thought about the design:
- An individual model for each type of product then a polymorphic
association in the cart so that it can handle all the types of
equipment. - A single product model that has fields for all types of equipment
with
a type field which can be checked when ever the product is used. - A product model with a price attribute then every type of product
extends that model.
But what is the best way in rails to handle these different types of
products?
TIA,
Dean