- I created my own API within my Rails app with ActiveModelSerializers, which takes ruby objects and converts them into JSON objects so I can pull data from those anywhere in my app. ActiveModelSerializers saves you from having to build our own JSON strings one by one.
- In order to prevent pages from refreshing every time we make a server request, what you need to do is hijack the click event of a link to fire an ajax request instead. That ajax request asks for the JSON data we can so conveniently get from our previously created API and gives us that data in the response.
- The last step is to do something with the response; you could append certain JSON elements to the DOM for example or when getting back the data from a form, ‘spit’ out the response right on that same page, no more redirects!