title: How must one implement a has_many alike system for different kind of models?
body: <p>I have several kinds of <code>Orders</code>; they differ quite a lot in the attributes and behaviour; but they share a common interface (Duck). Roughly like so:</p>
  
  <pre><code>class PackageOrder
    has_one :package
  
    def line_items
      [package, package.site.first]
    end
  end
  
  class SiteOrder
    has_one :site
  
    def line_items
      [site]
    end
  end
  
  class Customer
    has_many :package_orders
    has_many :site_orders
  end
  </code></pre>
  
  <p>Is there a way to abstract the various <code>orders</code> on Customer? So that I can say active-recordy things like: </p>
  
  <pre><code>Customer.orders
  Customer.orders &lt;&lt; PackageOrder.new
  </code></pre>
  
  <p>And that I don't have to add a <code>has_many</code> line whenever I introduce a new <code>Order</code> variation?</p>
  
  <p>I am not too familiar with all the possible usages of Polymorphic associations, so perhaps that offers a solution? Is this feasible at all?</p>
  
  <p>I could, obviously, do some magic on <code>Customer</code> (pseudocode warning)</p>
  
  <pre><code>class Customer
    ORDER_TYPES = [:package_order, :site_order]
    class_eval.do 
      ORDER_TYPES.each {|type| has_many type.pluralize.to_sym}
    end
  
    def orders
      ORDER_TYPES.map {|type| self.type.pluralize }.flatten
    end
  end
  </code></pre>
  
  <p>But I am wondering if ActiveRecord or Rails does not already offer something for me:</p>