RailsCasts Pro episodes are now free!

Learn more or hide this

Nathan Esquenazi's Profile

GitHub User: nesquena

Site: http://nesquena.github.com

Comments by Nathan Esquenazi

Avatar

One thing I have started doing recently for a few APIs is to support versioning simply using folders with RABL templating. Depending on your situation, it can greatly reduce code duplication. Simply setup a single api controller and then render the corresponding template based on a version parameter i.e render "#{params[:version]}/show" and then create templates for each version (users/v1/show, users/v2/show). Since the controller between versions is typically largely unchanged in most cases, this may be an alternative approach. If anyone is curious for more details, perhaps I can add a guide to the RABL wiki.

Avatar

Can you try again with RABL 0.6.4 if you get a chance and followup?

Avatar

As kind of an addendum to the link, at the time I wrote that (not too long ago) I saw honestly almost nobody talking about api (json) template building. At least not in my visible sphere.

Things have changed dramatically since then. Now with jbuilder, the revised json_builder, serializers, boxer, et al it seems that this space has gotten a lot of attention recently especially with the rise of Backbone. I consider this a very good thing. I think every api templater that has popped up has a valid use case and an interesting use case. Down with to_json :P

Avatar

Yes personally using RABL with Backbone (or Spine) and also with https://github.com/gazay/gon has made for a great combination for my projects. Anyone reading this might find https://github.com/nesquena/rabl/wiki/Backbone-Integration and https://github.com/nesquena/rabl/wiki/Flexible-Responses useful as well.

Avatar

Really happy to see Gon+RABL covered in this screencast. That has been my favored approach to passing data to javascript lately. Thanks Alexey for making the Gon gem (and integrating it with RABL) and thanks to Ryan for another great screencast.

Avatar

Yes, take a look at using the node keyword because this allows for very flexible responses. Just added the beginning of a guide for it here: https://github.com/nesquena/rabl/wiki/Flexible-Responses