Profile Picturethoughtbot

Backbone.js on Rails

2 ratings

Build snappier, more interactive apps with cleaner code and better tests in no time

You build web apps, and you’ve seen the shift towards highly interactive, rich client-side web applications. Over the past years, we’ve seen the same things, and have built our apps, processes, and best practices around this. Learn the better way to build rich, interactive applications using Backbone.js and Rails.

Download a free sample chapter.

More than just a book

In addition to the book (in HTML, PDF, EPUB, and Kindle formats), you also get a complete example application.

The book is written using Markdown and distributed via GitHub. When you purchase, we give you access directly to the repository, so you can use the GitHub comment and issue features to give us feedback about what we’ve written and what you’d like to see. Last but not least, also included is a complete sample Backbone.js and Rails application. What the book describes and explains, the example app demonstrates with real, working code. Fully up to date for Rails 3.2 and Backbone 1.0.

Table of Contents


  • Why use Backbone.js
  • The Example Application

Getting up to speed

  • Backbone.js online resources
  • JavaScript online resources and books


  • Backbone.js and MVC
  • What Goes Where
  • Namespacing your application
  • Mixins

Rails Integration

  • Organizing your Backbone.js code in a Rails app
  • Rails 3.0 and prior
  • Rails 3.1 and above
  • An Overview of the Stack: Connecting Rails and Backbone.js
  • Customizing your Rails-generated JSON
  • Converting an existing page/view area to use Backbone.js
  • Automatically using the Rails authentication token

Routers, Views, and Templates

  • View explanation
  • Templating strategy
  • Choosing a strategy (stub)
  • Routers
  • Event binding
  • Cleaning Up: Unbinding
  • Swapping router
  • Composite views
  • Forms
  • Internationalization

Models and collections

  • Model associations
  • Filters and sorting
  • Validations
  • Model relationships
  • Duplicating business logic across the client and server
  • Synchronizing between clients
  • Uploading attachments


  • Full-stack integration testing
  • Isolated unit testing
  • Example: Test-driving a Task application


  • XSS with JSON bootstrapping

The included example application illustrates a Rails 3.2 app with user authentication, nested model relationships, bootstrapped and lazily populated collections, and complete test coverage using Cucumber, RSpec, and Jasmine.

Add to cart

You'll get .pdf, .mobi, .epub, and .html files, plus access to the GitHub repository with the book's source code and an example Rails/Backbone app.

PDF Length
183 pages
Copy product URL


(2 ratings)
5 stars
4 stars
3 stars
2 stars
1 star

Backbone.js on Rails

2 ratings
Add to cart