Skip to content

Instantly share code, notes, and snippets.

View CatPerry's full-sized avatar
🏠
Working from home

Cat Perry CatPerry

🏠
Working from home
View GitHub Profile
@CatPerry
CatPerry / gist:bc65d5bceed4378ceac1fce25ed1dcff
Created May 9, 2018 21:57 — forked from victorwhy/gist:45bb5637cd3e7e879ace
How Sinatra routes PUT/PATCH and DELETE

HTML and Sinatra really only support the GET and the POST methods. In order to be able to use the PUT and DELETE methods in Sinatra, you kind of have to "trick" the form to go to the right place. Then you can name the routes the proper way - otherwise you can only really work with GET and POST.

I used the Craiglist Jr challenge for some examples. Let's look at a quick example of a POST form/method/route- in this case, we're creating a new Craigslist article:

POST form and corresponding route:

<form action="/article/new" method="post">
  --------------------------------
  YOUR FORM FIELDS HERE