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

Packagethief → October 16th, 2006 at 5:01 pm

I think in edge Rails, :post => true is deprecated in favor of :method => :post

Trey → October 22nd, 2006 at 4:00 am

And :method => :delete would be even better if you’re into REST.

What do you think about that?

Elsewhere in the empire: Home, Blog, APOD