Take the 2-minute tour ×

Is this a valid route handler?

post '/lists/:id/delete' do
   #delete list

I can't get it to fire.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Yes, it is. But it will only fire when you do a HTTP POST request, e.g. submit a form using the post method:

<form action="/lists/17/delete" method="post">

If you enter the same URL in you browser, however, a HTTP GET request will be fired. If this is what you want, you should replace post with get in your route.

A great place to start: http://www.sinatrarb.com/intro.

share|improve this answer
yep, I understand that. Nevertheless it is not fired when posting from a form. Here are the other routes, could one conflict? get '/lists' do get '/lists/:id' do put '/lists/:id' do post '/lists/:id/delete' do post '/lists/create' do –  Rom1 Mar 13 '11 at 11:37
I don't think the other routes should be in conflict in any way. –  gnab Mar 13 '11 at 11:39
Here is the erb template fragment: <td> <form action="<%= "/list/#{list.id}/delete" %>" method="post"> <input type="submit" value="Delete"> </form> –  Rom1 Mar 13 '11 at 11:39
list vs lists, maybe? :) –  gnab Mar 13 '11 at 11:44
Damn... Thanks, I always do shit like this (/me hides) –  Rom1 Mar 13 '11 at 11:47
add comment

Your Answer


