Skip to content

Commit d4d7946

Browse files
committed
building solution first
1 parent b0eb7b3 commit d4d7946

18 files changed

Lines changed: 195 additions & 35 deletions

File tree

.learn

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
tags:
2-
- tag1
2+
- sinatra
3+
- forms
4+
- html
35
languages:
4-
- language1
5-
resources: 0
6+
- ruby
7+
- html

CONTRIBUTING.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Contributing to Learn.co Curriculum
2+
3+
We're really exited that you're about to contribute to the [open curriculum](https://learn.co/content-license) on [Learn.co](https://learn.co). If this is your first time contributing, please continue reading to learn how to make the most meaningful and useful impact possible.
4+
5+
## Raising an Issue to Encourage a Contribution
6+
7+
If you notice a problem with the curriculum that you believe needs improvement
8+
but you're unable to make the change yourself, you should raise a Github issue
9+
containing a clear description of the problem. Include relevant snippets of
10+
the content and/or screenshots if applicable. Curriculum owners regularly review
11+
issue lists and your issue will be prioritized and addressed as appropriate.
12+
13+
## Submitting a Pull Request to Suggest an Improvement
14+
15+
If you see an opportunity for improvement and can make the change yourself go
16+
ahead and use a typical git workflow to make it happen:
17+
18+
* Fork this curriculum repository
19+
* Make the change on your fork, with descriptive commits in the standard format
20+
* Open a Pull Request against this repo
21+
22+
A curriculum owner will review your change and approve or comment on it in due
23+
course.
24+
25+
# Why Contribute?
26+
27+
Curriculum on Learn is publicly and freely available under Learn's
28+
[Educational Content License](https://learn.co/content-license). By
29+
embracing an open-source contribution model, our goal is for the curriculum
30+
on Learn to become, in time, the best educational content the world has
31+
ever seen.
32+
33+
We need help from the community of Learners to maintain and improve the
34+
educational content. Everything from fixing typos, to correcting
35+
out-dated information, to improving exposition, to adding better examples,
36+
to fixing tests—all contributions to making the curriculum more effective are
37+
welcome.

Gemfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ source "https://rubygems.org"
44
# gem "rails"
55

66
gem 'sinatra'
7-
gem 'rake'
8-
gem 'thin'
9-
gem 'shotgun'
10-
gem 'pry'
11-
gem 'require_all'
12-
7+
gem 'rake'
8+
gem 'thin'
9+
gem 'shotgun'
10+
gem 'pry'
11+
gem 'require_all'
12+
1313
group :test do
14-
gem 'rspec'
15-
gem 'capybara'
16-
gem 'rack-test'
17-
end
14+
gem 'rspec'
15+
gem 'capybara'
16+
gem 'rack-test'
17+
end

Gemfile.lock

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
rack (1.5.2)
5+
rack-protection (1.5.0)
6+
rack
7+
shotgun (0.9)
8+
rack (>= 1.0)
9+
sinatra (1.4.3)
10+
rack (~> 1.4)
11+
rack-protection (~> 1.4)
12+
tilt (~> 1.3, >= 1.3.4)
13+
tilt (1.4.1)
14+
15+
PLATFORMS
16+
ruby
17+
18+
DEPENDENCIES
19+
shotgun
20+
sinatra

README.md

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,50 @@
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+
![Imgur](http://i.imgur.com/zrbFWNE.png?1)
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+
![Imgur](http://i.imgur.com/SzO0phP.png?1)
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)

Rakefile

Lines changed: 0 additions & 9 deletions
This file was deleted.

app.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
require_relative 'config/environment'
1+
require 'sinatra/base'
22

33
class App < Sinatra::Base
4-
end
4+
5+
end

config/environment.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
require 'bundler/setup'
44
Bundler.require(:default, ENV['SINATRA_ENV'])
55

6-
require './app'
7-
require_all 'models'
6+
require './app'

models/.keep

Whitespace-only changes.

public/images/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)