I don't think this is a feature for rails. There is not only jbuilder. Take a look, for example, at ActiveModel Serializers : https://github.com/josevalim/active_model_serializers Which is, in my opinion, better than jbuilder, and where you don't have views for your json at all.
Also, in an API, versioning the rendering is not enough. You need to be able to version features if necessary. There are several existing solutions for this already, a bit different from yours. For example, biceps, which allows routing different versions differently. https://github.com/lyonrb/biceps Damien MATHIEU | Ingénieur logiciel 84, rue Chevreul | 69 007 Lyon Tel. : +33 (0)6 88 42 00 15 | http://dmathieu.com On 15 September 2012 11:18, Jim Jones <[email protected]> wrote: > My friend Ben Willis and I have developed a gem for the versioning of > Rails views. > https://github.com/bwillis/versioncake > > The versioning is done by the naming convention. Image the following > series of files : > > show.v3.json.jbuilder > show.v2.json.jbuilder > show.v1.json.jbuilder > > create.v2.json.jbuilder > create.v1.json.jbuilder > > The developer pre-defines all view versions in their config. When a > specific view version is specified (via a header or request param) , if the > version of that view exists, it is rendered, otherwise, the request > _degrades_ to the previous version. > > This makes it really handy for APIs/Jbuilder views. For example, if you > defined a new version for your API, e.g. v3, yet all other actions remain > the same, the degradation will automatically select the appropriate > backward compatible view (v2 for the create view above). > > The versioning functionality is passive meaning that if the version file > extensions aren't utilized, the end user (especially beginners) will not > know that the functionality exists. > > Our end goal is to merge and submit a pull request for Rails core. > > Would love to hear everyone's thoughts. > > Jim Jones > http://www.github.com/aantix > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-core/-/9POep66BvoMJ. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
