title: Rails POST forms to pretty URL
body: <p>Having one of those 'I'm clearly doing something wrong' moments. It feels like I'm trying to do something basic, and fighting the framework, so I'm appealing for help!</p>
  
  <p>I'm using Rails 3 and am a bit confused about how to make a search form that results in pages with clean URLs.</p>
  
  <p>My application allows you to search from routes from any location to another location.</p>
  
  <p>For example, a valid URL would be /routes/A/to/B/, or /routes/B</p>
  
  <p>My routes.rb:</p>
  
  <pre><code>match 'routes/:from/to/:to' =&gt; 'finder#find', :as =&gt; :find
  match 'routes/find' =&gt; 'finder#find'
  </code></pre>
  
  <p>My search form:</p>
  
  <pre><code>&lt;% form_tag('/routes, :method =&gt; 'post') do %&gt;
    &lt;%= label_tag(:from, "From:") %&gt;
    &lt;%= text_field_tag(:from) %&gt;
    &lt;%= label_tag(:to, "To:") %&gt;
    &lt;%= text_field_tag(:to) %&gt;
    &lt;%= submit_tag("Go") %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>class FinderController &lt; ApplicationController
    def index
    end
  
    def find
      if params[:from].blank? or params[:to].blank?
        render :action =&gt; "invalid_results" and return
      end
      @from = Location.find_by_code(params[:from].upcase)
      @to = Location.find_by_code(params[:to].upcase)
      if @from.nil? or @to.nil?
        render :action =&gt; "invalid_results" and return
      end
  
      @routes = Route.find_all_by_from_location_id_and_to_location_id(@from, @to)
  
    end
  end
  </code></pre>
  
  <p>When I use <code>:method =&gt; 'get'</code> in my <code>form_tag</code>, the application works, but the URL is hideous. And, of course, with <code>:method =&gt; 'post'</code>, the variables are no longer visible which is bad for bookmarking. How do I tell Rails to use my pretty URLs after POSTing the form?</p>
  
  <p>I am VERY new at Rails so your patience is appreciated.</p>