Skip to content

Commit

Permalink
Merge pull request #536 from daiki0381/correct-the-number-web-fundame…
Browse files Browse the repository at this point in the history
…ntals-tutorial

Correct the number
  • Loading branch information
vesan committed Aug 1, 2023
2 parents c1c2753 + 8d3d86f commit 5ccb6b4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions _pages/sinatra.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ If you're still stuck, [check here](https://tjmcewan.github.io/coffeecalc/snippe

If you're storing your params correctly, you should be able to refresh the browser and see that a new hash gets added to the `$coffees` array each time.

## *6.* Tidy Up
## *7.* Tidy Up

That big chunk of HTML in our `get` code is making it a bit hard to see what our app does. Let's move it to its own method.

Expand All @@ -241,7 +241,7 @@ This will also make it easier to re-use the form, should we ever need to.

**Hint:** [Check here](https://tjmcewan.github.io/coffeecalc/snippets/template_method.rb.txt) if something went awry.

## *7.* Moving Beyond GET
## *8.* Moving Beyond GET

As you saw in the store coffees section, if you refresh your browser, your app adds the information into the `$coffees` global variable repeatedly. This is because we're storing the params from the URL each time our `get` code is requested.

Expand All @@ -265,7 +265,7 @@ end

This is Sinatra's way of telling you that the route you requested doesn't exist. You may also know this as HTTP error number 404: *page not found*.

## *8.* Add Post
## *9.* Add Post

Let's *add* our `post` code into Sinatra (don't remove the get one!):

Expand All @@ -285,7 +285,7 @@ Remember GET requests are asking to fetch a resource, whereas POST requests are

However, if you refresh a page on a POST request, this means you are resending the POST request, and could be creating a new resource each time you refresh. That's why the browser gives you a warning before allowing you to do it.

## *9.* Add a Redirect
## *10.* Add a Redirect

In order to get around this form-resubmission problem, lets tell the browser to load a different page as soon as it receives the response to our `POST`. We do this using a special HTTP response known as a "redirect".

Expand Down

0 comments on commit 5ccb6b4

Please sign in to comment.