Adding Custom fields and methods to jsonapi resources
The problem
Recently, I have attempted to completely switch to JsonAPI specification for all my API-only rails projects. To achieve these with ease, I use Jsonapi resources gem. This gem is very handy to use and get’s you configured for JsonAPI specs in no time. But sometimes, its not clear how to do what you would normally do if you are not using the tool. One of those issues is adding custom fields to the json objects from the ActiveRecords being serialized. I will show you my solution to the this challenge.