Rails Line Items Help
i'm trying to figure out the best way to do shopping cart for bicycle components. the problem that i'm encountering is that i can't just add all the components to the same model because they each have different specs (i.e. a chainring has a column for "number_of_teeth" while a fork has a column for "crown_diameter").
right now i have a table for each component but that makes it difficult to look up information for that item in that i need to h开发者_StackOverflow社区ave each component listed in the controller which seems redundant. am i better off just making a components model and having a "type" column then adding a "specs" column that will connect to another table, say chainring_specs, that will have all of that information?
i want to get this set up the best way possible. thank you.
Yes, in my opinion, creating a more generic components model will give your web app a lot more flexibility. I'm assuming that you'll have a database feeding this shopping cart.
Your model(s) will be shaped by the type of back-end schema that you use. A one table schema that can support all of your components will allow you to handle skus, pricing, etc. in one place. Depending on the type of complexity that you face, you might want to have the description and specs in separate tables.
Hope this helps!
精彩评论