The controllers are the logical part of your application. They are Ruby classes which inherit from ApplicationController and contain methods. After a HTTP request goes through the routing process and has determined which controller to use for the request, the controller is responsible for performing the logical part of the request and producing the appropriate output.
Strong Parameters are located in the controller. They are a security feature of rails that prevents unwanted data from entering our database. This is helpful because it protects our database by only allowing a user to submit data that we explicitly permitted into our database.
Serializers are ruby gems that allow us to format our JSON data in a more organized way. In order to setup we need:
- Add to gem file and run ‘bundle install’
- Setup serializer files by running ‘rails g serializer shelter’ and ‘rails g serializer pet’
- Edit each files association info and attributes
- Make sure each controller action that needs to view json data has the appropriate serializer (ex. shown above in controller images- render json: @shelter) in order to render json
Happy coding ✌️