![]() ![]() With the Active Model Serializer gem, you can manage which attributes will be rendered and how they are rendered in a very simple way by using Active model serializers. Now imagine an application with lots of relationships and large models. Well, these are all small examples with just a few data points. All relationships and attributes are being rendered. As you know, slowness accumulates over time! Take a look at this JSON response. 'Poetic, comic, human' is how The Washington Post hailed Dona Flor and Her Two Husbands, the international classic by Jorge Amado, Brazil's foremost novelist. There is data you probably won’t need to render and another common problem is an increase in data over time, which can lead to slow page loading time. ![]() Why would you want to customize or modify your JSON response?īy default, rails API renders all data and this can be a problem. HarperCollins, 1969 - Fiction - 553 pages. A serializer allows you to decide which attributes and relationships will be rendered on your API which makes it possible to customize JSON data. What is the Active Model Serializer gem for and why do I need to serialize my data?Īctive Model Serializer is a Ruby gem that serializes data. In this post, I’ll show you why this gem is a must-have to develop better APIs and if you already use it but want to have a better understanding of how it works, this post is also for you. ![]() Active Model Serializer is by far my favorite gem. ![]() As Rubyists, we all know that ruby gems can make coding a little bit easier and this one is no different. ![]()
0 Comments
Leave a Reply. |