From 877900ab041535138ce9cafb7d39b7b30625807d Mon Sep 17 00:00:00 2001 From: KFad Date: Thu, 2 May 2019 15:20:05 -0400 Subject: [PATCH] create puppy adoption form --- app.rb | 15 ++++++++++++++- models/puppy.rb | 9 +++++++++ views/create_puppy.erb | 17 +++++++++++++++++ views/display_puppy.erb | 6 ++++++ views/index.erb | 11 +++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) diff --git a/app.rb b/app.rb index b1f74e9..9f3e662 100644 --- a/app.rb +++ b/app.rb @@ -1,5 +1,18 @@ require_relative 'config/environment' class App < Sinatra::Base + get '/' do + erb :index + end -end \ No newline at end of file + get '/new' do + erb :create_puppy + end + + post '/' do + @name = params[:name] + @breed = params[:breed] + @age = params[:age] + erb :display_puppy + end +end diff --git a/models/puppy.rb b/models/puppy.rb index e69de29..2b54bed 100644 --- a/models/puppy.rb +++ b/models/puppy.rb @@ -0,0 +1,9 @@ +class Puppy + attr_accessor :name, :breed, :age + + def initialize(name, breed, age) + @name = name + @breed = breed + @age = age + end +end diff --git a/views/create_puppy.erb b/views/create_puppy.erb index e69de29..e56f3f0 100644 --- a/views/create_puppy.erb +++ b/views/create_puppy.erb @@ -0,0 +1,17 @@ + + + + + title + + +

Puppies!

+
+

Puppy Name:

+

Puppy Breed:

+

Puppy Age:

+ +
+ + + diff --git a/views/display_puppy.erb b/views/display_puppy.erb index e69de29..c4f2e92 100644 --- a/views/display_puppy.erb +++ b/views/display_puppy.erb @@ -0,0 +1,6 @@ +

Pups!

+ +

Puppy Name: <%= @name %>

+

Puppy Breed: <%= @breed %>

+

Puppy Age: <%= @age %>

+ diff --git a/views/index.erb b/views/index.erb index e69de29..ac825ba 100644 --- a/views/index.erb +++ b/views/index.erb @@ -0,0 +1,11 @@ + + + + + title + + +

Puppies!

+ Click Here To List A Puppy + +