diff --git a/app/controllers/puppies_controller.rb b/app/controllers/puppies_controller.rb index ed1730d..b5cd7fc 100644 --- a/app/controllers/puppies_controller.rb +++ b/app/controllers/puppies_controller.rb @@ -1,6 +1,17 @@ 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 display the puppy + def index + @puppies = [] + end + + def show + end + + def new + @puppy = Puppy.new("", "", "") + end + + def create + @puppy = Puppy.new(params[:name], params[:breed], params[:age]) + render :create + end end diff --git a/app/models/puppy.rb b/app/models/puppy.rb index 77f6078..2b54bed 100644 --- a/app/models/puppy.rb +++ b/app/models/puppy.rb @@ -1,10 +1,9 @@ -# TODO: Build out your Puppy class here -# Your puppy should have name, breed, and age attributes -# You will need to be able to pass these three attributes to initialization -# as well as readers and writers for the attributes - class Puppy - # TODO: Add your code here - # Hint: You'll need attr_accessor for name, breed, and age - # You'll also need an initialize method that takes name, breed, and age as parameters + attr_accessor :name, :breed, :age + + def initialize(name, breed, age) + @name = name + @breed = breed + @age = age + end end diff --git a/app/views/puppies/create.html.erb b/app/views/puppies/create.html.erb index 6f54b98..21d5f67 100644 --- a/app/views/puppies/create.html.erb +++ b/app/views/puppies/create.html.erb @@ -1,11 +1,5 @@ - +
Puppy Name: <%= @puppy.name %>
+Puppy Breed: <%= @puppy.breed %>
+Puppy Age: <%= @puppy.age %>
diff --git a/app/views/puppies/index.html.erb b/app/views/puppies/index.html.erb index 2be4660..bf32704 100644 --- a/app/views/puppies/index.html.erb +++ b/app/views/puppies/index.html.erb @@ -1,10 +1,3 @@ - +<%= link_to "Click Here To List A Puppy", "/new" %> diff --git a/app/views/puppies/new.html.erb b/app/views/puppies/new.html.erb index 45ca039..5ea3b6b 100644 --- a/app/views/puppies/new.html.erb +++ b/app/views/puppies/new.html.erb @@ -1,11 +1,12 @@ - + <%= form.label :age %> + <%= form.text_field :age %> + + <%= form.submit "submit" %> +<% end %> diff --git a/config/routes.rb b/config/routes.rb index 4c97056..749b953 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,5 @@ Rails.application.routes.draw do - # TODO: Add your routes here - # You need: - # - A GET route to '/' that goes to the puppies controller index action - # - A GET route to '/new' that goes to the puppies controller new action - # - A POST route to '/puppy' that goes to the puppies controller create action + get '/', to: 'puppies#index' + get '/new', to: 'puppies#new' + post '/puppy', to: 'puppies#create' end diff --git a/db/schema.rb b/db/schema.rb index ae89000..1879966 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,5 +10,6 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 0) do +ActiveRecord::Schema.define(version: 2025_08_19_143654) do + end diff --git a/db/test.sqlite3 b/db/test.sqlite3 index 9fb98b5..f973236 100644 Binary files a/db/test.sqlite3 and b/db/test.sqlite3 differ diff --git a/models/puppy.rb b/models/puppy.rb deleted file mode 100644 index 77f6078..0000000 --- a/models/puppy.rb +++ /dev/null @@ -1,10 +0,0 @@ -# TODO: Build out your Puppy class here -# Your puppy should have name, breed, and age attributes -# You will need to be able to pass these three attributes to initialization -# as well as readers and writers for the attributes - -class Puppy - # TODO: Add your code here - # Hint: You'll need attr_accessor for name, breed, and age - # You'll also need an initialize method that takes name, breed, and age as parameters -end