Skip to content

Commit 81e64cc

Browse files
committed
Use a different URL for GET and POST
1 parent c9836d5 commit 81e64cc

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

tutorial.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ There is nothing extraordinary on this route. In fact it looks very similar to t
568568

569569
```
570570
<body>
571-
<form action="/new-book" method="post" >
571+
<form action="/new-book-save" method="post" >
572572
<p>
573573
<b>Title</b>
574574
<input type="text" id="title" name="title" />
@@ -585,9 +585,9 @@ This view introduces two new HTML elements: `<form>` and `<input>`.
585585

586586
HTML FORMs are a way to group the values that we want to pass to the server. These values are captured via `<input>` elements inside the `<form>`. The HTML FORM element itself has two *attributes* that are important:
587587

588-
* The `action` tells the browser the URL on the server *where* the information will be send to when the user clicks the "submit" button on their browser. In our example we are telling the browser to use the `/new-book` URL.
588+
* The `action` tells the browser the URL on the server *where* the information will be send to when the user clicks the "submit" button on their browser. In our example we are telling the browser to use the `/new-book-save` URL.
589589

590-
* The `method` tells the browser *how* to submit the information. In our case we are using the POST method which means that the browser will issue an `HTTP POST /new-book` when the user clicks the "submit" button.
590+
* The `method` tells the browser *how* to submit the information. In our case we are using the POST method which means that the browser will issue an `HTTP POST /new-book-save` when the user clicks the "submit" button.
591591

592592
The values that the browser will push to the server are captured via the `<input>` elements inside our HTML FORM. There are many kind of `<input>` elements but in this workshop we will only use two of them: text boxes and submit buttons.
593593

@@ -597,12 +597,12 @@ Submit buttons are used to give the user a button to indicate they are ready to
597597

598598
The `id` and `name` attributes in `<input>` elements are important since this is the way the *server* will recognize each of the data elements that it receives.
599599

600-
All of the above means that when the users clicks the "submit button" in our form the browser will issue an `HTTP POST /new-book` request and it will pass to the server the values in the `<input>` elements, in our case *title*, *author*, and *year*.
600+
All of the above means that when the users clicks the "submit button" in our form the browser will issue an `HTTP POST /new-book-save` request and it will pass to the server the values in the `<input>` elements, in our case *title*, *author*, and *year*.
601601

602602
Our `webdemo3_books.rb` has a route to handle this particular HTTP POST request. The code is below:
603603

604604
```
605-
post("/new-book") do
605+
post("/new-book-save") do
606606
# Get the values submitted on the HTML FORM...
607607
title = params["title"]
608608
author = params["author"]

views/book_new.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
The value of the HTML INPUT elements will be send to the server
1010
as part of the HTTP POST
1111
-->
12-
<form action="/new-book" method="post" >
12+
<form action="/new-book-save" method="post" >
1313
<p>
1414
<b>Title</b><br/>
1515
<input type="text" id="title" name="title" placeholder="Enter book title" />

webdemo3_books.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
end
4646

4747
# Save the information of a new book
48-
post("/new-book") do
48+
post("/new-book-save") do
4949
# Get the values submitted on the HTML FORM...
5050
title = params["title"]
5151
author = params["author"]

0 commit comments

Comments
 (0)