title: how to avoid repetition with identical models in rails
body: <p>In my project I have two models which have identical attributes, methods and everything the same. </p>
  
  <p>at the moment they are in app/models/ in separate rb files, with quite some repetition of code. </p>
  
  <p>I would like to export all that code to a separate file and have the two files referring to it, and have mode DRY code. </p>
  
  <p>I've tried the following, but it didn't work: </p>
  
  <pre><code># app/models/order.rb
  class Order &lt; ActiveRecord::Base
    before_save { self.version += 1 }
  
    attr_accessible :order
    attr_accessible :filled_date
  
    validates :order, :presence =&gt; true
  end
  </code></pre>
  
  <p>and one of the referring orders is: </p>
  
  <pre><code># app/models/real_order.rb
  class RealOrder &lt; Order
    belongs_to :User, inverse_of: :real_orders
  end
  </code></pre>
  
  <p>but this doesn't work, and I get a <code>Could not find table 'orders'</code> when I try to use the models.</p>
  
  <p>Also I'm thinking that <code>Orders</code> is not a real model, so probably the <code>app/models</code> is not really the right place for that file, though I'm not sure in what directory it should be. </p>
  
  <p>thanks, </p>
  
  <p>UPD1: 
  The structure I would like to achieve in the end is a situation where I have two identical database tables, with two separate models that are based on the same code. I would like to write such code only once in a separate superclass file. So I'm looking for DRY code, not DRY database. </p>