Need suggestion for groups of related options

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?

TIA,

Sean

Your suggestion is what I thought of initially too:

Product
has_many :colors, :class_name => ‘Variation’, :conditions =>
“option_id = 1”
has_many :sizes, :class_name => ‘Variation’, :conditions => “option_id
= 2”

mike

schof wrote:

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?