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?
>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---