Backbone and Rails Nested Routes

I have the following routes defined in rails:

resources :accounts do
  resources :transactions

This results in urls like:


Is there an easy way to map this to a backbone model set up?


Turns out backbone quite easily supports this by nesting a collection in a model as follows:

var Account = Backbone.Model.extend({

  initialize: function() {
    this.transactions = new TransactionsCollection;
    this.transactions.url = '/account/' + + '/transactions';
    this.transactions.bind("reset", this.updateCounts);

This achieves exactly what I wanted.

You can read more about it here:

Need Your Help

How to access an already-running Application Context from a Sync Adapter service in Android?

service sync android

I have an app that consists of several activities, and I use the Application Context (entended from the Application Class, and I made it persistent) to share data and objects between all the activi...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.