Skip to content

learn-co-students/phrg-sinatra-basic-forms-lab-pca-000

Repository files navigation

Sinatra Basic Forms Lab

Your local pet adoption store has asked you to build their new website. First and foremost, the store needs a form for their staff to add puppies that are available for adoption. Good thing you love puppies and coding!

Objectives

  1. Implement a POST request to the controller to display data from a user in the view
  2. Implement both POST and GET requests
  3. Connect a controller action with both a view and a model

Instructions

The focus of this lab is to build a way for a user to go to a homepage, follow a link to a form where they can enter a puppy's information, and, upon submission, view the puppy's information.

  1. Build out a puppy class in models/puppy.rb. Puppies 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.

  2. In app.rb build out a GET request to load a homepage. The homepage should go to the main route /.

  3. The home page will also need a new view index.erb. This page should welcome you to the Puppy Adoption Site. Add this view to the controller action.

  4. Now, we need to create a form for a user to list a new puppy that is available for adoption. You can create this form in views/create_puppy.erb. Remember, you'll need to set up another controller action for a user to be able to view this form in the browser. Another reminder: the "submit" button of a form is an <input> element with a type of "submit", not a <button> element.

  5. Now we need to make sure the form is being submitted properly. You'll need to have a third controller action that takes the input from the user and renders a third view (views/display_puppy.erb) which displays the info for the puppy that was just created.

  6. Add a link on the homepage to the new puppy form.

Does this need an update?

Please open a GitHub issue or pull-request. Provide a detailed description that explains the issue you have found or the change you are proposing. Then "@" mention your instructor on the issue or pull-request, and send them a link via Connect.

View Sinatra Basic Forms Lab on Learn.co and start learning to code for free.

PHRG Sinatra Basic Forms Lab

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages