diff --git a/app/controllers/puppies_controller.rb b/app/controllers/puppies_controller.rb index ed1730d..222a7c6 100644 --- a/app/controllers/puppies_controller.rb +++ b/app/controllers/puppies_controller.rb @@ -1,6 +1,16 @@ 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 + end + + def new + @puppy = Puppy.new + end + + def create + @puppy = Puppy.new( + name: params[:name], + breed: params[:breed], + age: params[:age] + ) + end end diff --git a/app/models/puppy.rb b/app/models/puppy.rb index 77f6078..d324ddc 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: nil, breed: nil, age: nil) + @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..bc1d9c4 100644 --- a/app/views/puppies/create.html.erb +++ b/app/views/puppies/create.html.erb @@ -1,11 +1,7 @@ - +