CRUD Application: Part 3
Learn to add the update and delete functionality to your application.
We'll cover the following...
We'll cover the following...
So far, your app allows you to perform the C and R of the CRUD operations. We can look at existing pets, retrieve their details, and create new ones.
Next, you will learn how to perform the U and D on our app. Here are the steps you will follow:
- Edit the editaction inapp/controllers/pets_controller.rbto take you to the edit view
- Edit edit.html.erbto display the form to edit existing pets.3. Create anupdatemethod inapp/controllers/pets_controller.rbto handle form updates
- Edit index.html.erbandshow.html.erbto display Edit links
- Create a destroymethod to handle pet removal
- Edit index.html.erbandshow.html.erbto display Remove links
Updating pets
Edit the edit action
You will modify your edit action in the app/controllers/pets_controller.rb file by adding the following line:
@pet = Pet.find(params[:id])
This is the same as what you did for your show action.