title: A simple way to do inheritance in rails with relations
body: <p>In Rails 4.2 I need some kind of inheritance for this structure:</p>
  
  <ul>
  <li><code>User</code> has many <code>Reports</code>, <code>Report</code> belongs to <code>User</code></li>
  <li><code>ImpactReport</code> is a <code>Report</code></li>
  <li><code>ChallengeReport</code> is a <code>Report</code></li>
  <li><code>PlanningReport</code> is a <code>Report</code></li>
  <li><code>StImpactReport</code> is an <code>ImpactReport</code></li>
  </ul>
  
  <p>I've read about single-table inheritance supported by Rails, but I don't think it would let me go two levels deep on inheritance, also <code>StImpactReport</code> has a bunch of fields that are not in <code>ImpactReport</code></p>
  
  <p>I've also seen a lot of articles about how to implement muti-table inheritance, but they all seem quite complex, when in my head there's a much simpler way to do it.</p>
  
  <p>I think it could be done simply with the <code>belongs_to</code> relationship in conjunction with <code>delegate</code> and <code>accepts_nested_attributes_for</code> like this:</p>
  
  <pre><code>class Report &lt; ActiveRecord::Base
  end
  
  class ImpactReport &lt; ActiveRecord::Base
    belongs_to :report
    accepts_nested_attributes_for :report
    delegate :user, to: :report
    delegate :other_report_field, to: :report
  end
  </code></pre>
  
  <p>and so on...</p>
  
  <p>The advantages of this are:</p>
  
  <ul>
  <li>I have separate tables for each model, but only the fields specific to that model are in their tables, common fields are in the table of the parent.</li>
  <li>I can go as many levels deep as I like</li>
  <li>I can have, say, an <code>impact_report</code> and a <code>challenge_report</code> that both share the same <code>report</code> attributes. When the attribute is changed in one the other is also changed. (this is good for my app)</li>
  </ul>
  
  <p>Disadvantages:</p>
  
  <ul>
  <li>It doesn't use class inheritance so methods of parents are not accessible to the children</li>
  </ul>
  
  <p>My questions are these:</p>
  
  <ol>
  <li>Are there any other disadvantages to this way of doing inheritance that I haven't thought of? Will it limit my application in some unforeseen way?</li>
  <li>If I have a <code>report</code> object, what is the best way for me to access all the attributes of the children of this object?</li>
  <li>If doing this structure, would it be better to use <code>has_one</code> instead of <code>belongs_to</code>?</li>
  </ol>