From d01f974ee4d9f17287d597f98568559ee5e4c7ce Mon Sep 17 00:00:00 2001 From: Lauren Abrams Date: Fri, 29 Jun 2018 13:43:16 -0400 Subject: [PATCH] finished sinatra basic forms lab --- app.rb | 16 +++++++++++++++- models/puppy.rb | 9 +++++++++ views/create_puppy.erb | 9 +++++++++ views/display_puppy.erb | 5 +++++ views/index.erb | 3 +++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/app.rb b/app.rb index b1f74e9..e48fa2a 100644 --- a/app.rb +++ b/app.rb @@ -2,4 +2,18 @@ class App < Sinatra::Base -end \ No newline at end of file + get '/' do + erb :index + end + + get '/new' do + erb :create_puppy + end + + post '/puppy' 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..05d50af 100644 --- a/views/create_puppy.erb +++ b/views/create_puppy.erb @@ -0,0 +1,9 @@ +
+ + + + + + + +
diff --git a/views/display_puppy.erb b/views/display_puppy.erb index e69de29..6fbd83f 100644 --- a/views/display_puppy.erb +++ b/views/display_puppy.erb @@ -0,0 +1,5 @@ + +

Puppy Name: <%= @name %>

+

Puppy Breed: <%= @breed %>

+

Puppy Age: <%= @age %>

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

Welcome to the puppy adoption site!

+ +Click Here To List A Puppy