Skip to content
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
13 changes: 12 additions & 1 deletion app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@

class App < Sinatra::Base

end
get '/' do
erb :index
end

get '/new' do
erb :create_puppy
end

post '/new' do
erb :display_puppy
end
Comment on lines +13 to +15
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to use the Puppy class here. You could initialize it with the params, then have access it in the view.

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)
@breed = breed
@name = name
@age = age
end
end
21 changes: 21 additions & 0 deletions views/create_puppy.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Puppy Adoption</title>
</head>
<body>
<form action="/new" method="POST">
<br>
<label for="name">Puppy Name:</label>
<input type="text" id="name" name="name" /><br>
<br>
<label for="breed">Breed:</label>
<input type="text" id="breed" name="breed"/><br>
<br>
<label for="age">Age:</label>
<input type="text" id="age" name="age" /><br>
<br>
<input id="submit" type="submit" value="Submit">
</form>
</body>
12 changes: 12 additions & 0 deletions views/display_puppy.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Puppy Adoption</title>
</head>
<body>
<h1>Puppy Name:</h1><p> <%= params[:name] %></p>
<h1> Puppy Breed:</h1> <p><%= params[:breed] %> </p>
<h1> Puppy Age:</h1> <p> <%= params[:age] %></p>
</body>
4 changes: 4 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<body>
<h1>Welcome</h1>
<a href='/new'>Click Here To List A Puppy</a>
</body>