× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Building Rails API using Active Model Serializer

<p>Justin was struggling with the task of building a Rails API and we met here at codementor!</p> <p>I gave Justin the basics of Rails API and explained how it works and I also gave him a quick overview on different tools/gems such as Jbuilder, Active Model Serializer, Grape, RABL etc. as options for building his API. I also explained pros and cons of each of these options and after a quick discussion and looking at his needs, we decided to use Active Model Serializer for building Justin's brand new Rails API which will expose video related information for different users and will be consumed by several client applications such as iOS and Android.</p> <p>As Justin was fairly new to the Rails world, to make him comfortable and to make sure he understands what we were doing and why we were doing it that way, I explained some basics of Rails (convention over configuration principle, DRY etc.), APIs, Active Record Associations and why we needed that, how the underlying database system works etc. Along with that, I also pointed him to some useful resources so that he could take the learning experience to the next level by going through those resources.</p> <p>Justin picked the concepts quickly as I explained and at the end of the session, we built a basic version of the API having a few associated models and related data. I showed him how to expose model and non-model attributes using Active Model Serializer and how to expose associated model data in an API endpoint. I also showed him a bunch of <em>gotchas</em> that I learned over the years while building APIs using Rails which he liked a lot. Other than building the API, I gave him a bunch of tips about the Rails best practices and how to learn it effectively which he appreciated and found very useful for his learning and growth.</p>
comments powered by Disqus