DRYing the app
Understand how to make your Ruby on Rails app more maintainable by eliminating repeated code in controllers and views. This lesson shows how to create private methods for strong parameters and partial views to share common form code for new and edit actions, enhancing your app's structure and readability.
We'll cover the following...
There are several parts of our application that share the same code. This goes against one of the principles of Rails: DRY.
So you will be going back and DRYing your application.
DRYing the actions
You may have noticed (params.require( :pet).permit( :name, :age, :description)) used in the update method is the same as you did for your create method. You can make this section cleaner by creating a private method that handles the parameter permissions.
So, open the app/controllers/pets_controller.rb file and add the following ...