开发者

Rails Line Items Help

开发者 https://www.devze.com 2023-03-28 20:55 出处:网络
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 h

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消