Skip to main content

Why do you choose ams (active model serializer) over jbuilder or the other way around? (Rails API)

Gems / Libraries • Asked by Drilon Buzuku

Hey Guys,

I'm interested in knowing, why some developers choose ams over jbuilder and some prefer jbuilder over ams, to build Rails based API's.

Cheers,

Drilon


Mostly the reason why AMS is used over jBuilder is that it's agnostic from the format. You can choose to output AMS in different formats using different adapters like the JSON API adapter. This means you can define the attributes and relationships of your data that you want to export, but you don't have to match that exactly with the JSON format. It becomes more interchangeable that way and you can make modifications a bit easier.

jBuilder is a lot more manual building out the exact structure of the JSON which makes it a bit harder to work with generally.


I'm new to this subject too and this is a good question & answer. Based on what you said, Chris;

jBuilder is a lot more manual building out the exact structure of the JSON which makes it a bit harder to work with generally.

Is it possible that jBuilder would be considered a starting point in a Payloads lifecycle? Based on what I just watched you demo jbuilder it seems that it's pretty simple to begin with. Is it normal to see both implementations in a code base? jbuilder for the simpler more static content and grow to AMS when needed?



Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.