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

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

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?


Join the discussion

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

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

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

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.