Skip to content

Commit 521f52c

Browse files
committed
solution
0 parents  commit 521f52c

22 files changed

Lines changed: 288 additions & 0 deletions

.gitignore

Whitespace-only changes.

.learn

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tags:
2+
- tag1
3+
languages:
4+
- language1
5+
resources: 0

.rspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--color
2+
--format documentation
3+
--require spec_helper

Gemfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# A sample Gemfile
2+
source "https://rubygems.org"
3+
4+
# gem "rails"
5+
6+
gem 'sinatra'
7+
gem 'rake'
8+
gem 'thin'
9+
gem 'shotgun'
10+
gem 'pry'
11+
gem 'require_all'
12+
13+
group :test do
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.3)
20+
coderay (~> 1.1.0)
21+
method_source (~> 0.8.1)
22+
slop (~> 3.4)
23+
rack (1.6.4)
24+
rack-protection (1.5.3)
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.1)
44+
rack (>= 1.0)
45+
sinatra (1.4.6)
46+
rack (~> 1.4)
47+
rack-protection (~> 1.4)
48+
tilt (>= 1.3, < 3)
49+
slop (3.6.0)
50+
thin (1.6.4)
51+
daemons (~> 1.0, >= 1.0.9)
52+
eventmachine (~> 1.0, >= 1.0.4)
53+
rack (~> 1.0)
54+
tilt (2.0.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.6

LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Learn.co Educational Content License
2+
3+
Copyright (c) 2015 Flatiron School, Inc
4+
5+
The Flatiron School, Inc. owns this Educational Content. However, the Flatiron School supports the development and availability of educational materials in the public domain. Therefore, the Flatiron School grants Users of the Flatiron Educational Content set forth in this repository certain rights to reuse, build upon and share such Educational Content subject to the terms of the Educational Content License set forth [here](http://learn.co/content-license) (http://learn.co/content-license). You must read carefully the terms and conditions contained in the Educational Content License as such terms govern access to and use of the Educational Content.
6+
7+
Flatiron School is willing to allow you access to and use of the Educational Content only on the condition that you accept all of the terms and conditions contained in the Educational Content License set forth [here](http://learn.co/content-license) (http://learn.co/content-license). By accessing and/or using the Educational Content, you are agreeing to all of the terms and conditions contained in the Educational Content License. If you do not agree to any or all of the terms of the Educational Content License, you are prohibited from accessing, reviewing or using in any way the Educational Content.

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Sinatra Basic Forms Lab
2+
3+
<img src="https://s3.amazonaws.com/learn-verified/puppies.gif" hspace="10" align="right" width="300">
4+
5+
Your local pet adoption store has asked you (a frequent dog walker and vistor) to build their new site because their old one was built in WordPress and sucks. Good thing you love puppies and coding!
6+
7+
## Objectives
8+
9+
1. Implement a POST request to the controller to display data from a user in the view
10+
2. Implement both POST and GET requests
11+
3. Connect a controller action with both a view and a model
12+
13+
## Get Building
14+
15+
### Step 1:
16+
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 3 attributes to initialization, as well as readers and writers for the attributes.
17+
18+
### Step 2:
19+
20+
In `app.rb` build out a GET request to load a home page. The home page should go to the main route `/`.
21+
22+
23+
### Step 3:
24+
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.
25+
26+
27+
### Step 4:
28+
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.
29+
30+
### Step 5:
31+
32+
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/dislay_puppy.erb`) which displays the info for the puppy that was just created.
33+
34+
### Step 6:
35+
36+
Add a link to the homepage to link to the new puppy form.
37+
38+
39+

Rakefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ENV["SINATRA_ENV"] ||= "development"
2+
3+
require_relative './config/environment'
4+
5+
# Type `rake -T` on your command line to see the available rake tasks.
6+
7+
task :console do
8+
Pry.start
9+
end

app.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require_relative 'config/environment'
2+
3+
class App < Sinatra::Base
4+
5+
get '/' do
6+
erb :index
7+
8+
end
9+
10+
get '/new' do
11+
erb :create_puppy
12+
end
13+
14+
post '/puppy' do
15+
@puppy = Puppy.new(params[:name], params[:breed], params[:age])
16+
erb :display_puppy
17+
end
18+
end

config.ru

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require './config/environment'
2+
3+
run App

0 commit comments

Comments
 (0)