Search⌘ K
AI Features

CRUD Application: Part 2

Explore how to build a CRUD application in Ruby on Rails by creating links, forms, and controller actions to create, read, and show records. Learn to manage routes and work with parameters for practical app development.

So far, your app opens the index.html.erb view for you and displays all the pets in our record as clickable links.

Next, we want to do the following:

  1. Edit index.html.erb to display a link to create a new pet.
  2. Edit new.html.erb to display web forms to set attributes for the new pet.
  3. Create a create method in your app/controllers/pets_controller.rb file to handle the creation of a new pet.
  4. Edit show.html.erb to display details of a pet when you click it.

Adding new pet

Edit the index view

In your app/views/pets/index.html.erb file you need ...