Backbone.js is a great library for creating single page applications that consume RESTful JSON services. Ruby on Rails does well at generating RESTful APIs and speaking JSON. In order to get the Rails working really well with Backbone, there are two tricks to do.
First, add the following line to the application controller to make the output look like what backbone expects.
Second take advantage of the : only option in to_json to limit the attributes included in the serialised json object. The documentation for this isn’t quite there in the latest rails, but the 2.3 to_json method describes it. http://apidock.com/rails/ActiveRecord/Serialization/to_json.
With these two simple tricks rails will generate the json that backbone wants, and you’ll have a happy front-end developer.