Skip to content
This repository has been archived by the owner on Jan 6, 2019. It is now read-only.

How is this gem different to backbone rails?

meleyal edited this page Nov 9, 2011 · 11 revisions

In response to: http://news.ycombinator.com/item?id=3214955

The main focus was to follow the naming conventions from thoughtbot and keep it simple.

The specific differences are:

  • Different naming conventions
  • Fewer generators
  • Generates Coffee or JS

Naming

The backbone-rails gem creates the following structure (using the default install + scaffold commands):

app/assets/
├── javascripts
    ├── application.js
    └── backbone
        ├── my_app.js.coffee
        ├── models
        │   └── cat.js.coffee
        ├── routers
        │   └── cats_router.js.coffee
        ├── templates
        │   └── cats
        │       ├── cat.jst.ejs
        │       ├── edit.jst.ejs
        │       ├── index.jst.ejs
        │       ├── new.jst.ejs
        │       └── show.jst.ejs
        └── views
            └── cats
                ├── cat_view.js.coffee
                ├── edit_view.js.coffee
                ├── index_view.js.coffee
                ├── new_view.js.coffee
                └── show_view.js.coffee

This gem creates the following structure (using the default install + scaffold commands):

app/assets/
├── javascripts
│   ├── application.js
│   ├── my_app.js.coffee
│   ├── collections
│   │   └── cats.js.coffee
│   ├── models
│   │   └── cat.js.coffee
│   ├── routers
│   │   └── cats_router.js.coffee
│   └── views
│       └── cats
│           └── cats_index.js.coffee
└── templates
    └── cats
        └── index.jst.eco

Why? I prefer the thoughtbot conventions as they are closer to what I was creating myself manually.

Generators

backbone-rails provides rails-like generators for each component (model, router, etc.).

This gem has only two generators, one for setting up the project structure (backbone:install), and one that creates all the files for a single resource in one go with minimal boilerplate (backbone:scaffold).

Why? This was done mainly for simplicity, to keep the gem easy to maintain.

Coffee or JS

Files can be generated as CoffeeScript (.js.coffee) or JavaScript (.js).

Why? The simple generators made it easy to add support for both.

Clone this wiki locally