title: How do I generate appropriate route helpers for an inherited resource in Ruby on Rails using single table inheritance (STI)
body: <p>I have two resources: FaxRequest and InternetRequest that both inherit from Request. I generated each of the three resources using the <code>rails scaffold resource</code> command and then modified the models to inherit from Request like this:</p>
  
  <pre><code>#request.rb
  class Request &lt; ActiveRecord::Base
  end
  
  #fax_request.rb
  class FaxRequest &lt; Request
  end
  
  #internet_request.rb
  class InternetRequest &lt; Request
  end
  </code></pre>
  
  <p>I would like to have a view that has a table showing all Requests (both FaxRequests and InternetRequests) together. I have this implemented as the index view of the Request controller.</p>
  
  <pre><code>#request_controller.rb
  def index
    @requests = Request.all
  end
  
  
  #views/requests/index.html.haml
  =@requests.each do |request|
    = request.date
    = link_to('show', request)
    = link_to('edit', ?)
    = link_to('delete' ?)
  </code></pre>
  
  <p>I see that <code>link_to('view', request)</code> is smart enough to generate a link to the appropriate resource, but <strong>how does Rails know whether to generate an <code>edit_fax_request_path(request)</code> or <code>edit_internet_request_path(request)</code></strong> based on the subclass of the request? Same goes for new and delete?</p>
  
  <p>Secondarily, I'm curious to know what the idomatic approach to STI is.  One controller or three in this case?  Am I going about the problem all wrong.  It seems to me that Rails would have a tidy way of dealing with this problem, yet I've googled and can't find anything.  Perhaps I'm not asking the right question?</p>