Tuesday, December 4, 2012

Delete route not showing up in rails 3

I wanted to add a destroy action to my rails controller. My routes file looked like so:
match "applications/:id" => 'applications#show'
delete "applications/:id" => "applications#destroy"

But no matter what I did, the destroy action never got called. This is because match is above delete, overriding it. You must switch the order in which you call them in routes or else delete will get superseded.

delete "applications/:id" => "applications#destroy"
 match "applications/:id" => 'applications#show'

Works.