Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Easily use backbone.js with rails 3.1

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 script
Octocat-spinner-32 test
Octocat-spinner-32 vendor
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 backbone-rails.gemspec
README.md

Backbone-Rails

Easily setup and use backbone.js with rails 3.1

Rails 3.1 setup

This gem requires the use of rails 3.1, coffeescript and the new rails asset pipeline provided by sprockets.

This gem vendors the latest version of underscore.js and backbones.js for Rails 3.1 and greater. The files will be added to the asset pipeline and available for you to use.

Installation

In your Gemfile, add this line:

gem "rails-backbone"

Then run the following commands:

bundle install
rails g backbone:install

Layout and namespacing

Running rails g backbone:install will create the following directory structure under app/assets/javascripts/backbone:

controllers/
models/
templates/
views/

It will also create a toplevel app_name.coffee file to setup namespacing and setup initial requires.

Generators

backbone-rails provides 3 simple generators to help get you started using bacbone.js with rails 3.1

Model Generator

rails g backbone:model

This generator creates a backbone model and collection inside app/assets/javascript/backbone/models to be used to talk to the rails backend.

Controller

rails g backbone:controller

This generator creates a backbone controller with corresponding views and templates for the given actions provided.

Scaffolding

rails g backbone:scaffold

This generator creates a controller, views, templates, model and collection to create a simple crud single page app

Something went wrong with that request. Please try again.