title: Rails best practice for similar controllers/views?
body: <p>I'm writing an inventory management Rails app. I have <code>class Product &lt; ActiveRecord::Base</code>, <code>class Foo &lt; Product</code> and <code>class Bar &lt; Product</code>. Foo and Bar have subtly different behavior, but using single-table inheritance is great for them.</p>
  
  <p>The problem is with the controllers and views. Currently I have them <em>completely</em> separate, which works, but contains a ton of repeated code. One could literally be generated from the other by copying the two directories and replacing <code>@foo</code>, <code>@foos</code>, and <code>Foo</code> with <code>@bar</code>, <code>@bars</code>, and <code>Bar</code>. As I add new features, it's irritating to add them twice. And, of course, it's not the Rails Way to not DRY.</p>
  
  <p>So what's the correct approach here? For the controllers...should I make a <code>ProductsController</code> and then just use metaprogramming magic to sub in either <code>Foo</code> or <code>Bar</code>? Or use inheritance? For the views, should I only have a products view, but use clever routing to make it look like I have separate (and RESTful) <code>/foos</code> and <code>/bars</code> paths?</p>
  
  <p>Thanks.</p>