50 Experience
0 Lessons Completed
0 Questions Solved


I'm working on an app that allows merchants to order products from a wholesaler.  On a fundamental level, there are a lot of similarities to a traditional e-commerce app, but there are also some differences.

I've tried coming at this from a few directions, but Im yet to find a good solution.  Here are my models

class Merchant
  has_many :orders

class ProductLine
  has_many :products
  has_many :option_groups, as: :option_groupable

class Product
  belongs_to :product_line
  has_many :option_groups, as: :option_groupable
  has_many :options, through: :option_groups

class OptionGroup
  belongs_to :option_groupable, polymorphic: true
  has_many :options

So a merchant user will be able to log in and create an order, then add products to the order, each product will have options that can be selected.  Options are grouped into option groups.  Some option groups should allow users to select multiple options, and others should allow a user to select only one option from the group.

Typically, merchants will be ordering a relatively small set of products, in larger quantities.  So for example, a merchant may order a set of 100 of X product, with XYZ options attached.

Has anyone ever encountered a situation like this?  What approach would you recommend?