title: Where to put common code found in multiple models?
body: <p>I have two models that contain the same method:</p>
  
  <pre><code>def foo
    # do something
  end
  </code></pre>
  
  <p>Where should I put this?</p>
  
  <p>I know common code goes in the <strong><code>lib</code> directory</strong> in a Rails app.</p>
  
  <p>But if I put it in a new class in <code>lib</code> called '<code>Foo</code>', and I need to add its functionality to both of my <code>ActiveRecord models</code>, do I do that like this:</p>
  
  <pre><code>class A &lt; ActiveRecord::Base
  includes Foo
  
  class B &lt; ActiveRecord::Base
  includes Foo
  </code></pre>
  
  <p>and then both <code>A</code> and <code>B</code> will contain the <code>foo</code> method just as if I had defined it in each?</p>