diff --git a/app/controllers/puppies_controller.rb b/app/controllers/puppies_controller.rb
index d682f57..28810c9 100644
--- a/app/controllers/puppies_controller.rb
+++ b/app/controllers/puppies_controller.rb
@@ -1,9 +1,24 @@
class PuppiesController < ApplicationController
- # TODO: Add your controller actions here
- # You'll need an 'index' action to display the homepage
- # You'll need a 'new' action to display the form
- # You'll need a 'create' action to process the form submission and redirect to show
- # You'll need a 'show' action to display the puppy information
- #
- # Remember: After creating a puppy, you should redirect to the show page
+ def index
+ @puppies = Puppy.all
+ end
+
+ def show
+ @puppy = Puppy.find(params[:id])
+ end
+
+ def new
+ @puppy = Puppy.new
+ end
+
+ def create
+ puppy = Puppy.create!(puppy_params)
+ redirect_to puppy_path(puppy)
+ end
+
+ private
+
+ def puppy_params
+ params.require(:puppy).permit(:name, :breed, :age)
+ end
end
diff --git a/app/views/puppies/index.html.erb b/app/views/puppies/index.html.erb
index 237462e..643305b 100644
--- a/app/views/puppies/index.html.erb
+++ b/app/views/puppies/index.html.erb
@@ -1,10 +1,13 @@
-
+<%= link_to "Click Here To List A Puppy", new_puppy_path %>
diff --git a/app/views/puppies/new.html.erb b/app/views/puppies/new.html.erb
index 7eacde8..546e5eb 100644
--- a/app/views/puppies/new.html.erb
+++ b/app/views/puppies/new.html.erb
@@ -10,3 +10,22 @@
Hint: Use form_with helper with a model parameter instead of url parameter
This will automatically set the correct action and method
-->
+
+<%= form_with model: @puppy, local: true do |form| %>
+ <%= form.label :name %>
+ <%= form.text_field :name %>
+
+
+
+ <%= form.label :breed %>
+ <%= form.text_field :breed %>
+
+
+
+ <%= form.label :age %>
+ <%= form.text_field :age %>
+
+
+
+ <%= form.submit id: "submit" %>
+<% end %>
diff --git a/app/views/puppies/show.html.erb b/app/views/puppies/show.html.erb
index b8ad62d..ed00ef6 100644
--- a/app/views/puppies/show.html.erb
+++ b/app/views/puppies/show.html.erb
@@ -1,11 +1,3 @@
-
+
Puppy Name: <%= @puppy.name %>
+Puppy Breed: <%= @puppy.breed %>
+Puppy Age: <%= @puppy.age %>
diff --git a/config/routes.rb b/config/routes.rb index 07741f6..857ce39 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,3 @@ Rails.application.routes.draw do - # TODO: Add your routes here - # You need to use RESTful routing conventions - # Hint: Use the resources method to create all the standard RESTful routes - # This will create routes for index, show, new, create, edit, update, and destroy + resources :puppies, only: [:index, :show, :new, :create] end