Introducing JsonApiable, Because Building RESTful JSON:APIs in Ruby Should Be Easier

If you are building a REST API on Ruby/Rails and decide to implement it as a JSON:API to avoid bike-shedding, chances are you are using fast_jsonapi or active_model_serializers gem to serialize your resources (if you still haven’t decided which one to use, go with fast_jsonapi). Both are geared towards serializing your resources into JSON responses, but the problem is, neither offers easy-to-use tools to consume API requests, and so you are left to write your own parsers to convert JSON:API relationships and complex attributes in, say, update requests into Rails-friendly params. That’s where JsonApiable enters the picture.

Continue reading “Introducing JsonApiable, Because Building RESTful JSON:APIs in Ruby Should Be Easier”

Moving from ActiveModel::Serializers to FastJsonAPI

I have used ActiveModel::Serializers for serializing data for JSON APIs for over a year now. I wasn’t happy with it. The performance was mediocre at best and the frequent breaking changes between versions meant that upgrading to newer ones was painful. So when Netflix open-sourced fast_jsonapi with its promise of superior performance and clean codebase, I was ready move on. Continue reading “Moving from ActiveModel::Serializers to FastJsonAPI”

Adding Recurrence Rule to Generated ICS file in Rails

If you need to integrate your Rails app with some calendaring service, such as Google Calendar, sooner or later you will find yourself writing code that outputs your Event object as an ICS file. But if your events have recurrence rules, you are out of luck, the popular Icalendar gem doesn’t support them. I’ll show how to make it work. Continue reading “Adding Recurrence Rule to Generated ICS file in Rails”

Document your Rails API by Writing Acceptance Specs

So you have been working on a Rails API, and now you need to create a browsable HTML documentation for it. One popular approach is to generate the docs from comments in the code. The problem with this is that comments are often not updated together with the code, and the documentation quickly becomes outdated. Recently I have started using an interesting alternative: Rspec Api Documentation. Continue reading “Document your Rails API by Writing Acceptance Specs”

Integrate ConverseJS with Rails The Easy Way

If you ever needed to add chat to your Rails app, than you are probably familiar with the ConverseJS library, which is a great XMPP/Jabber compatible javascript client. But until today there was no asset-pipeline compatible gem that would add converse.js and converse.css to your app. As you probably know, adding external js and css files manually isn’t ideal, since it makes it harder to maintain and update versions.

Well, now there is: Continue reading “Integrate ConverseJS with Rails The Easy Way”