Skip to content

Commit 33a6202

Browse files
committed
Merge pull request #2 from learn-co-curriculum/lesson
Created Lesson - closes #1
2 parents b0eb7b3 + d1f32a7 commit 33a6202

18 files changed

Lines changed: 257 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: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
capybara (2.5.0)
5+
mime-types (>= 1.16)
6+
nokogiri (>= 1.3.3)
7+
rack (>= 1.0.0)
8+
rack-test (>= 0.5.4)
9+
xpath (~> 2.0)
10+
coderay (1.1.0)
11+
daemons (1.2.3)
12+
diff-lcs (1.2.5)
13+
eventmachine (1.0.8)
14+
method_source (0.8.2)
15+
mime-types (2.6.2)
16+
mini_portile (0.6.2)
17+
nokogiri (1.6.6.2)
18+
mini_portile (~> 0.6.0)
19+
pry (0.10.1)
20+
coderay (~> 1.1.0)
21+
method_source (~> 0.8.1)
22+
slop (~> 3.4)
23+
rack (1.5.2)
24+
rack-protection (1.5.0)
25+
rack
26+
rack-test (0.6.3)
27+
rack (>= 1.0)
28+
rake (10.4.2)
29+
require_all (1.3.2)
30+
rspec (3.3.0)
31+
rspec-core (~> 3.3.0)
32+
rspec-expectations (~> 3.3.0)
33+
rspec-mocks (~> 3.3.0)
34+
rspec-core (3.3.2)
35+
rspec-support (~> 3.3.0)
36+
rspec-expectations (3.3.1)
37+
diff-lcs (>= 1.2.0, < 2.0)
38+
rspec-support (~> 3.3.0)
39+
rspec-mocks (3.3.2)
40+
diff-lcs (>= 1.2.0, < 2.0)
41+
rspec-support (~> 3.3.0)
42+
rspec-support (3.3.0)
43+
shotgun (0.9)
44+
rack (>= 1.0)
45+
sinatra (1.4.3)
46+
rack (~> 1.4)
47+
rack-protection (~> 1.4)
48+
tilt (~> 1.3, >= 1.3.4)
49+
slop (3.6.0)
50+
thin (1.6.3)
51+
daemons (~> 1.0, >= 1.0.9)
52+
eventmachine (~> 1.0)
53+
rack (~> 1.0)
54+
tilt (1.4.1)
55+
xpath (2.0.0)
56+
nokogiri (~> 1.3)
57+
58+
PLATFORMS
59+
ruby
60+
61+
DEPENDENCIES
62+
capybara
63+
pry
64+
rack-test
65+
rake
66+
require_all
67+
rspec
68+
shotgun
69+
sinatra
70+
thin
71+
72+
BUNDLED WITH
73+
1.10.3

README.md

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,51 @@
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+
# Basketball Season!
2+
3+
## Description
4+
5+
In this lab, you'll practice building forms in Sinatra by creating a basketball team sign-up sheet. Your application will have a basic html form, and will display the data from the form after it has been submitted by the user.
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 `/team`.
15+
2. Add a form to the `team.erb` template and render it in the GET `/team` route.
16+
3. The form should have fields for:
17+
18+
+ Team name ('name')
19+
+ Coach ('coach')
20+
+ Point Guard ('pg')
21+
+ Shooting Guard ('sg')
22+
+ Power Forward ('pf')
23+
+ Small Forward ('sf')
24+
+ Center ('c')
25+
26+
It should look something like this:
27+
28+
![form for basketball team](https://curriculum-content.s3.amazonaws.com/web-development/Sinatra/basketball-form.png)
29+
30+
### Handle form submission
31+
32+
1. Create a route that responds to a POST request at `/team`
33+
2. Have the form send a POST request to this route.
34+
3. Upon submission, pass the submitted data to the `newteam.erb` template.
35+
36+
## Final Output
37+
38+
Update the `newteam.erb` template so when you post to this form, it displays the name of the team and each member of the team.
39+
40+
Your view should display something like this:
41+
42+
![completed form](https://curriculum-content.s3.amazonaws.com/web-development/Sinatra/basketball-results.png)
43+
44+
## Deliverables
45+
46+
Pass the tests!
47+
48+
## Resources
49+
* [Ashley William's GitHub](https://github.com/ashleygwilliams/) - [Sinatra Form Party](https://github.com/ashleygwilliams/sinatra-form-party)
50+
51+
* [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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
require_relative 'config/environment'
1+
require 'sinatra/base'
22

33
class App < Sinatra::Base
4-
end
4+
5+
6+
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)