Categorized: Rails
Making a POST link in Rails
You know you shouldn’t be using GETs (URLs) for deleting things, right? Here’s how you do it in Rails:
<%= link_to "Destroy account", { :action => "destroy" }, :confirm => "Are you sure?", :post => true %>
(example is from the API docs)
:post => true! That’s awesome. Of course, it’s not unobtrusive, but maybe UJS could fix that.
Comments
I think in edge Rails, :post => true is deprecated in favor of :method => :post
And
:method => :deletewould be even better if you’re into REST.What do you think about that?