• This repository has been archived on 06/Jan/2019
  • Stars
    star
    808
  • Rank 56,414 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 13 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple gem for using Backbone.js with Rails.

Backbone on Rails

A simple gem for using Backbone.js with Rails.

http://git.io/backbone-on-rails

Features

  • Vendors the latest Backbone.js + Underscore.js in the asset pipeline

  • Provides an install generator to create a skeleton directory structure and manifest

  • Provides a scaffold generator to create files and boilerplate

  • Uses the naming conventions from thoughtbot's Backbone.js on Rails

  • Generates CoffeeScript (default) or JavaScript

Usage

gem 'backbone-on-rails'

bundle install

rails generate backbone:install

rails generate backbone:scaffold NAME

Note: Remember to restart the server after installing

See also:

Output

Example output from backbone:scaffold planet

app/assets/
โ”œโ”€โ”€ javascripts
โ”‚   โ”œโ”€โ”€ application.js
โ”‚   โ”œโ”€โ”€ space_app.js.coffee
โ”‚   โ”œโ”€โ”€ collections
โ”‚   โ”‚   โ””โ”€โ”€ planets.js.coffee
โ”‚   โ”œโ”€โ”€ models
โ”‚   โ”‚   โ””โ”€โ”€ planet.js.coffee
โ”‚   โ”œโ”€โ”€ routers
โ”‚   โ”‚   โ””โ”€โ”€ planets_router.js.coffee
โ”‚   โ””โ”€โ”€ views
โ”‚       โ””โ”€โ”€ planets
โ”‚           โ””โ”€โ”€ planets_index.js.coffee
โ””โ”€โ”€ templates
    โ””โ”€โ”€ planets
        โ””โ”€โ”€ index.jst.eco

Tricks

# Custom manifest
rails generate backbone:install --manifest index.js

# Generate JavaScript
rails generate backbone:install --javascript

# Custom Appname
rails generate backbone:install --app=CustomApp

# Place code within a sub directory structure
rails generate backbone:install --dir=custom_app

# Remove generated files
rails destroy backbone:scaffold planet

# Create a custom app name
rails generate backbone:scaffold planet -a=CustomApp

# Generate scaffold in sub directory of assets/javascripts & assets/templates
rails generate backbone:scaffold planet -d=custom_app

# Use Handlebars File instead of JST
rails generate backbone:scaffold planet --template=hbs

# Use SHT instead of JST as template namespace
rails generate backbone:scaffold planet --template_namespace=SHT

Alternatives

For other features check out: