|
1 | | -# Basic Sinatra Forms Lab |
2 | | - |
3 | | -## Teacher outline |
4 | | -The lab should consist of: |
5 | | -+ Students creating html forms on multiple get routes |
6 | | -+ Creating 'Post' routes for each form in the controller |
7 | | -+ Manipulating the data in params and seting to instance variables |
8 | | -+ Render the data in the instance variables in new .erb files |
| 1 | +# Superheroes! |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +In this lab, you'll practice building nested forms in Sinatra for creating teams of superheros. No database is required, but feel free to add persistence *after* you have successfully completed the instructions below. |
| 6 | + |
| 7 | +## Instructions |
| 8 | + |
| 9 | +1. `bundle install` |
| 10 | +2. `bundle exec shotgun` |
| 11 | + |
| 12 | +### Make a form |
| 13 | + |
| 14 | +1. Create a route that responds to a GET request at `/`. |
| 15 | +2. Create a view with a form and render it in the GET `/` route. |
| 16 | +3. The form should have fields for the `name` of a superhero team and their `motto`. |
| 17 | +4. There should be form inputs for each of the three superhero member's `name`, `power`, and `bio`. |
| 18 | + |
| 19 | +It should look something like this: |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +### Handle form submission |
| 24 | + |
| 25 | +1. Create a route that responds to a POST request at `/teams` |
| 26 | +2. Have the form send a POST request to this route. |
| 27 | +2. Upon submission, render a template that displays the submitted team data and each member's data. |
| 28 | + |
| 29 | +## Final Output |
| 30 | + |
| 31 | +Your params should be nested. For example, you would access the first super-hero's name as: |
| 32 | + |
| 33 | +```ruby |
| 34 | +params["team"]["members"][0][name] |
| 35 | +``` |
| 36 | + |
| 37 | +When you post to this form you should render a page that displays the name of the team and each member of the team, along with their name, super power and bio. |
| 38 | + |
| 39 | +Your view should display something like this: |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +## Deliverables |
| 44 | + |
| 45 | +Pass the tests! |
| 46 | + |
| 47 | +## Resources |
| 48 | +* [Ashley William's GitHub](https://github.com/ashleygwilliams/) - [Sinatra Form Party](https://github.com/ashleygwilliams/sinatra-form-party) |
| 49 | + |
| 50 | +* [Ashley William's GitHub](https://github.com/ashleygwilliams/) - [Citibike Sinatra](https://github.com/ashleygwilliams/citibike-sinatra) |
0 commit comments