Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finished lab #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@

class App < Sinatra::Base

end
get "/" do
erb :index
end

get "/new" do
erb :create_puppy
end

post "/" do
@puppy = Puppy.new(params[:name], params[:breed], params[:age])
erb :display_puppy
end
end
9 changes: 9 additions & 0 deletions models/puppy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Puppy
attr_accessor :name, :breed, :age

def initialize(name, breed, age)
@name = name
@breed = breed
@age = age
end
end
9 changes: 9 additions & 0 deletions views/create_puppy.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1>List a Puppy</h1>

<form method="post" action="/">
<h1>Enter puppy information:</h1>
<p>Puppy Name: <input type="text" name="name"></p>
<p>Puppy Breed: <input type="text" name="breed"></p>
<p>Puppy Age: <input type="text" name="age"></p>
<button type="submit" value="submit">Submit</button>
</form>
5 changes: 5 additions & 0 deletions views/display_puppy.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<body>
<p>Puppy Name: <%= @puppy.name %></p>
<p>Puppy Breed: <%= @puppy.breed %></p>
<p>Puppy Age: <%= @puppy.age %></p>
</body>
11 changes: 11 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>title</title>
</head>
<body>
<h1>Welcome to the Puppy Adoption Site!</h1>
<a href="http://localhost:9393/new">"Click Here To List A Puppy"</a>
</body>
</html>