I’m working on a rails based e-commerce plugin. I have a situation
where I have a single product and I want to present either multiple
groups of radio buttons or a series of combo boxes for each of the
product variations. For example, the product has several different
options for color and size. I would want to show two combos, one for
price and one for size.
Product :has_many variations
Variation :belongs_to option, :belongs_to option_value
Product#variations will return a mix of color and size option values
lumped together. I’m looking for a convenient way to get at the
distinct groups based on option type. The first idea that jumps to
mind is to use SQL to get the distinct list of types and then do a few
more queries but that seems query intensive.
Any suggestions on the best way to accomplish this in Rails?