I have been trying to figure out how eBay would create their forms in rails. (FYI I know that they don’t use rails). So far I have come to the conclusion that their could be two models
Posts "<- would contain the basics every post contains"
-
Post_id
User_id
Category_id
Photos
Title
condition
Location
Price
This is pretty simple, but lets say a user wants to sell a car, the form would ask them for the mileage, model, year etc. But in contrast, if a user wants to sell a table, the form would not ask for the information it would generally ask for a car. Is their a way to accomplish this is rails without having to create many models and associating them with Posts?
I guess the simplest scenario would be thus:
“Category has a name” (this will keep “car”, “bird”, “soul”, whatever they sell on e-bay)
“Property is made of a name, a value and a category”
“Product has many Properties”
Each product will have N properties belonging to a certain category.
Use-case (new category):
When you create a new category, you can create properties belonging to it, or add properties from existing other categories (composition)
Use-case (new product):
When you want to create a new product, you select a category and properties belonging to that category will be added dynamically to your product.