title: Rails route for button
body: <p>I'm a rails newbie and a question on routes is confusing me.</p>
  
  <p>On one of my pages, I have a form.  In that form I allow the user to fill in some needed information and press a "submit" button.</p>
  
  <p>I get:</p>
  
  <pre><code>No route matches {:action=&gt;"inventory_test", :controller=&gt;"test_types"}
  </code></pre>
  
  <p>I do have an action in the test_type controller for "inventory_test".</p>
  
  <p>My confusion is that routes seem to be defined according to the REST model, such as /Users/edit/1.  That's fine, but how does one create routes for things like buttons?</p>
  
  <p>I may be naive, but it seems like if I tried to setup a route in the form:</p>
  
  <pre><code>match 'some/url' =&gt; 'controller#action'
  </code></pre>
  
  <p>then I'm essentially defining the action for the entire page.  How do I define actions for elements on the page?</p>
  
  <p>When this button is clicked, I want the action in the controller called.  I'm looking for:</p>
  
  <pre><code>match "submit_button" =&gt; 'test_types#inventory_test'
  </code></pre>
  
  <p>I realize I'm likely misunderstanding the paradigm, so any education is greatly appreciated.</p>
  
  <hr>
  
  <p>Code:
  (Note that I haven't tested the form code yet, but hopefully you get the idea)</p>
  
  <pre><code>index.html.haml
  
  %div
  
    %table
      %caption 
        Inventory Tests
        %form
          Inventory Run: %input {:type =&gt; 'text', :name=&gt;'inventory_run'}
          Inventory Class: %input {:type =&gt; 'text', :name=&gt;'inventory_class'}
          =button_to "Run Inventory Test", :action =&gt; 'inventory_test';
  </code></pre>