Analytics Rating App with Rails...and now with JS too!
The first thing I wanted to do was to be able to render json data from my action methods. I updated my index and show controllers adding a respond_to method and block and this allowed me to go for example to my index page, add .json to the url and now I'm able to get all of my courses data in json format. Below you can see an example of how my controllers were before and after adding the previous functionality.
JSON DATA ACCESSED FROM URL
I then added the active model serializer gem to be able to specify any course attributes I wanted in my json data. I worked with model associations for the serializer as well to identify relationships between my different classes and models. For example, working with courses they have many ratings therefore I implemented a has_many association for it.
Time to start learning React so expect a new blog post soon!