I’m using Rails 3.1 here, and I’ve got the following code in my view:
<%= link_to "again!", main_pick_path,{:method => :post, :var => @var} %>
The idea is to create a link (not a button) which, when clicked, calls the pick action of the main controller, passing the value of @var in params via a POST request.
This code generates the following HTML in my browser:
a href="/main/pick" data-method="post" rel="nofollow" var="foo">again!</a>
However when I click the link I am still sending a GET request. Is this a limitation of my browser, Chrome? From a design standpoint, should I be using a GET request instead and putting the variable into the URL? Are hyperlinks simply incapable of using the POST method? Is there life after death?
Thanks in advance
You can only do this with AJAX or firing a FORM. The tag A cant do a POST “alone”.