Search code examples
ruby-on-railsruby-on-rails-3backbone.jsbackbone-viewsbackbone-routing

Backbone.js and rails Code organization


I am working on a app that has multiple types of users, each user has a separate view when they are logged in. for example a business type user will create his profile upload photos etc, create some other stuff. and then the content created by businesses is visible public on the web-app's landing page.

I am using backbone on the client side, but the whole web app isn't all backbone, the business management area is a separate part which a backbone app runs on the client side, and now I am looking to start on the public landing page, I am confused on how to make this work, should I create a new backbone app for this page, or stuff more views models and collections into the same app?

The urls of both pages differ one is like whatever.com/business and the landing page is at whatever.com

Many views and models from the business side are the same as needed on the public landing page. But I can't think of a good solution on how to organize this.

Has any one worked on something like this before. Any insights ?

Thanks


Solution

  • Backbone.js is a great MVC framework but there isn't a whole lot of convention around organising a large application. You need to be familiar with some good design patterns to get the most out of it or it quickly gets messy.

    I was looking at AMD earlier. It looks nice:
    http://backbonetutorials.com/organizing-backbone-using-modules/

    THis might help too:
    http://ricostacruz.com/backbone-patterns/

    I also enjoyed this rule book on designing a good API. It was only $8 on my kindle!
    http://www.amazon.com/REST-API-Design-Rulebook-ebook/dp/B005XE5A7Q

    Edit: I recently refactored a large backbone.js application. I found it a lot easier to build if I exploited Javascript event driven architecture.