title: How to list all the models that belong to another model?
body: <p>I'm building a small system for a restaurant.</p>
  
  <p>I'm currently stuck at listing efficiently all the models that belong to a <code>product_type</code> the types are: <code>food</code>, <code>beverages</code>, and <code>apparel_items</code>.</p>
  
  <p>Each product Type has multiple kinds of products that belong to them for example <code>food</code> has many <code>wraps</code>, many <code>salads</code>, many <code>sandwiches</code>, etc.</p>
  
  <p>The point of this is to have a button for each of the Product Types which when clicked, depending on the id of the type selected, lists all the models that belong to it as buttons so in turn you can click any of them and then list the database records for the model in question.</p>
  
  <p>Example: Food, Beverages => click food => shows buttons for: wraps, salads and sandwiches => click wraps => Lists all the wraps </p>
  
  <pre><code>class ProductType &lt; ActiveRecord::Base
    has_many :apparel_items
    has_many :chapata_items
    has_many :combos
    has_many :croissants
    has_many :fruits
    has_many :green_challenges
    has_many :hot_drinks
    has_many :infusions
    has_many :juices
    has_many :molletes
    has_many :omelettes
    has_many :salads
    has_many :sandwiches
    has_many :shakes
    has_many :sincronizadas
    has_many :slices
    has_many :smooth_drinks
    has_many :super_drinks
    has_many :water_drinks
    has_many :wrap_items
  end
  </code></pre>
  
  <p>How can I list all the models that belong to another one so that I can program this efficiently?</p>
  
  <p>Would it be better to create a model for each of the Product Types (Food, Beverages, Apparel Items) and make only those three belong to the Product Type model?</p>