Ask A Question

Notifications

You’re not receiving notifications from this thread.

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

Drilon Buzuku asked in Gems / Libraries

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

Reply

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.

Reply
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?


Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,796+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.