title: Rails: One Inherited Comment Model vs Two Slightly Differing Comment Models
body: <p>I have the current (simplified) Model setup -- basically two very different models:</p>
  
  <pre><code>Product
  - Title
  
  Restaurant
  - Title
  
  Comment
  - Message
  - gps_cords (sometimes?!)
  </code></pre>
  
  <p>My goal is to let people leave comments on both <code>products</code> and <code>restaurants</code> at will based on this criteria: </p>
  
  <ol>
  <li>When someone comments on a product the comment should simply have a <code>message</code>.</li>
  <li>When someone comments on a restaurant the comment should have a <code>message</code> AND a <code>gps_cords</code> value.</li>
  </ol>
  
  <p>These are what I'm considering:</p>
  
  <p>Scenario 1: One big ass table w/ inheritance models</p>
  
  <pre><code>class Product &lt; ActiveRecord::Base
    has_many :product_comments
  end
  
  class Restaurant &lt; ActiveRecord::Base
    has_many :restaurant_comments
  end
  
  class Comment &lt; ActiveRecord::Base
    # message -&gt; string
    # gps_cords -&gt; string
    # type -&gt; string
  end
  
  class ProductComment &lt; Comment
    # only uses message
    belongs_to :product
  end
  
  class RestaurantComment &lt; Comment
    # uses message AND gps_cords
    belongs_to :restaurant
  end
  </code></pre>
  
  <p>Scenario 2: "Duplicate" efforts w/ two comment models</p>
  
  <pre><code>class Product &lt; ActiveRecord::Base
    has_many :product_comments
  end
  
  class Restaurant &lt; ActiveRecord::Base
    has_many :restaurant_comments
  end
  
  class ProductComment &lt; ActiveRecord::Base
    # message -&gt; string
    belongs_to :product
  end
  
  class RestaurantComment &lt; ActiveRecord::Base
    # gps_cords -&gt; string
    # message -&gt; string
    belongs_to :restaurant
  end
  </code></pre>
  
  <p>What is the correct way to model this giving consideration to: </p>
  
  <ol>
  <li>Performance</li>
  <li>Ability to query for "All comments"</li>
  <li>"Rails way" ? (if there is)</li>
  <li>Where would indexes go?</li>
  </ol>
  
  <p>Thank you very much to the people who take time to read all of this. </p>