RailsCasts Pro episodes are now free!

Learn more or hide this

Jim Jones's Profile

GitHub User: aantix

Site: http://www.jimasks.me

Comments by Jim Jones

Avatar

Why put everything in a separate controller for API? Image a separate API registration controller and a standard web controller; changes are made to the web controller forgetting to make the same changes to the API controller.

This is the problem that the respond_to blocks are suppose to help solve.

Take a look at VersionCake ( https://github.com/bwillis/versioncake ); easily set the API version in the request header. The appropriate view is then rendered for the request (e.g. show.v1.json.jbuilder). If the requested version of the view doesn't exist, the next prior version is rendered ensuring backwards compatibility.