|
2 | 2 |
|
3 | 3 | <img src="https://s3.amazonaws.com/learn-verified/puppies.gif" hspace="10" align="right" width="300">
|
4 | 4 |
|
5 |
| -Your local pet adoption store has asked you (a frequent dog walker and visitor) to build their new site because their old one was built in WordPress and sucks. Good thing you love puppies and coding! |
| 5 | +Your local pet adoption store has asked you to build their new website. First |
| 6 | +and foremost, the store needs a form for their staff to add puppies that are |
| 7 | +available for adoption. Good thing you love puppies _and_ coding! |
6 | 8 |
|
7 | 9 | ## Objectives
|
8 | 10 |
|
9 |
| -1. Implement a POST request to the controller to display data from a user in the view |
| 11 | +1. Implement a POST request to the controller to display data from a user in |
| 12 | +the view |
10 | 13 | 2. Implement both POST and GET requests
|
11 | 14 | 3. Connect a controller action with both a view and a model
|
12 | 15 |
|
13 | 16 | ## Instructions
|
14 | 17 |
|
15 |
| -1. Build out a puppy class in `models/puppy.rb`. Puppies should have name, breed, and age attributes. You will need to be able to pass these three attributes to initialization, as well as readers and writers for the attributes. |
| 18 | +The focus of this lab is to build out a way for a user to go to a 'homepage,' |
| 19 | +follow a link to a form where they can enter a puppy's information, and, upon |
| 20 | +submission, view the puppy's information. |
16 | 21 |
|
17 |
| -2. In `app.rb` build out a GET request to load a home page. The home page should go to the main route `/`. |
| 22 | +1. Build out a puppy class in `models/puppy.rb`. Puppies should have name, |
| 23 | +breed, and age attributes. You will need to be able to pass these three |
| 24 | +attributes to initialization, as well as readers and writers for the attributes. |
18 | 25 |
|
19 |
| -3. The home page will also need a new view `index.erb`. This page should welcome you to the Puppy Adoption Site. Add this view to the controller action. |
| 26 | +2. In `app.rb` build out a GET request to load a home page. The home page |
| 27 | +should go to the main route `/`. |
20 | 28 |
|
21 |
| -4. Now, we need to create a form for a user to list a new puppy that is available for adoption. You can create this form in `views/create_puppy.erb`. Remember, you'll need to set up another controller action for a user to be able to view this form in the browser. Another reminder: the "submit" button of a form is an `<input>` element with a `type` of `"submit"`, *not* a `<button>` element. |
22 |
| - |
23 |
| -5. Now we need to make sure the form is being submitted properly. You'll need to have a third controller action that takes the input from the user and renders a third view (`views/display_puppy.erb`) which displays the info for the puppy that was just created. |
24 |
| - |
25 |
| -6. Add a link on the homepage to the new puppy form. |
| 29 | +3. The home page will also need a new view `index.erb`. This page should |
| 30 | +welcome you to the Puppy Adoption Site. Add this view to the controller action. |
26 | 31 |
|
| 32 | +4. Now, we need to create a form for a user to list a new puppy that is |
| 33 | +available for adoption. You can create this form in `views/create_puppy.erb`. |
| 34 | +Remember, you'll need to set up another controller action for a user to be |
| 35 | +able to view this form in the browser. Another reminder: the "submit" button |
| 36 | +of a form is an `<input>` element with a `type` of `"submit"`, *not* a |
| 37 | +`<button>` element. |
27 | 38 |
|
| 39 | +5. Now we need to make sure the form is being submitted properly. You'll need |
| 40 | +to have a third controller action that takes the input from the user and |
| 41 | +renders a third view (`views/display_puppy.erb`) which displays the info for |
| 42 | +the puppy that was just created. |
28 | 43 |
|
29 |
| - |
30 |
| -<p data-visibility='hidden'>View <a href='https://learn.co/lessons/sinatra-basic-forms-lab' title='Sinatra Basic Forms Lab'>Sinatra Basic Forms Lab</a> on Learn.co and start learning to code for free.</p> |
31 |
| - |
32 |
| -<p data-visibility='hidden'>View <a href='https://learn.co/lessons/sinatra-basic-forms-lab'>Sinatra Basic Forms Lab</a> on Learn.co and start learning to code for free.</p> |
| 44 | +6. Add a link on the homepage to the new puppy form. |
33 | 45 |
|
34 | 46 | <p class='util--hide'>View <a href='https://learn.co/lessons/sinatra-basic-forms-lab'>Sinatra Basic Forms Lab</a> on Learn.co and start learning to code for free.</p>
|
0 commit comments