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

create puppy adoption form #8

Open
wants to merge 1 commit 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
15 changes: 14 additions & 1 deletion app.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
require_relative 'config/environment'

class App < Sinatra::Base
get '/' do
erb :index
end

end
get '/new' do
erb :create_puppy
end

post '/' do
@name = params[:name]
@breed = params[:breed]
@age = 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
17 changes: 17 additions & 0 deletions views/create_puppy.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>title</title>
</head>
<body>
<h1>Puppies!</h1>
<form method="post" action="/">
<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>
<input type="submit" value="submit">
</form>
</body>
</html>

6 changes: 6 additions & 0 deletions views/display_puppy.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Pups!</h1>

<p>Puppy Name: <%= @name %></p>
<p>Puppy Breed: <%= @breed %></p>
<p>Puppy Age: <%= @age %></p>

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>Puppies!</h1>
<a href="/new">Click Here To List A Puppy</a>
</body>
</html>