title: Rails 3 link_to generator for :post, :put, & :delete?
body: <p>I recently ran into this problem: <a href="https://stackoverflow.com/questions/4342083/rails-3-link-to-method-delete-not-working">Rails 3 link_to (:method =&gt; :delete) not working</a></p>
  
  <p>In which I was confused why my <code>link_to 'test', test_path(:test =&gt; test), :method =&gt; :post</code> wasn't working (why it was GETting rather than POSTing). As the post above suggests, it was because I didn't have the Rails javascript files, which handles dynamically making the form on-the-fly for <code>:post</code>, <code>:put</code> &amp; <code>:delete</code>.</p>
  
  <p>I'm not sure I especially like relying on javascript to do this for me, as I'd like my app to be fully functional with javascript disabled; it's how I like to develop (so I know I've got all my Rails programming functionality works correctly), and when I do wire my app up with javascript, I don't have to worry about duplicating this functionality, since I usually wipe the stock javascripts file generated by Rails.</p>
  
  <p>I read somewhere that, technically, hyperlinks (anchor elements) should only really be used for GET requests, and that buttons (as part of form elements) should be used for the other methods. </p>
  
  <p>So, my two questions:</p>
  
  <ol>
  <li>Is there a gem out there that will rewrite any <code>link_to ... :method =&gt;</code> in my view to a form element on-the-fly when my views are rendered? </li>
  <li>If not, how would I hook into the view parser to write my own? (using HAML, preferrably)</li>
  </ol>
  
  <p>Essentially, what I would like is to write this in my HAML file:</p>
  
  <pre><code>= link_to 'Test Link', some_path(:with =&gt; some_resource), :method =&gt; :post
  </code></pre>
  
  <p>... and have my rendered HTML output come out with this:</p>
  
  <pre><code>&lt;form action="some_path?with=some_resource" method="post"&gt;
    &lt;!-- insert appropriate _method hidden field here --&gt;
    &lt;!-- add appropriate csrf token and whatnot --&gt;
    &lt;button type="submit"&gt;Test Link&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>... so that all the <code>link_to</code> helpers with defined methods (thus, will not affect plain links whose verb is GET) will work <em>without javascript</em>?</p>
  
  <hr>
  
  <p>I'd also appreciate any thoughts about the <em>why</em> part of this question, specifically why the Rails team decided to keep this functionality tied to javascript rather than doing this through pure HTML?</p>