A clone of codebrew/backbone-rails with updated Backbone, Underscore, and jquery-rails versions.
Provides Backbone & Underscore files and modifies Backbone to:
- include the Rails authenticity token in HTTP requests
- nest model attributes within the declared paramRoot , EG,
var Book = Backbone.Model.extend({
url: '/books',
paramRoot: 'book'
});
var book_instance = new Book({
title: 'the illiad',
author: 'homer'
});
book_instance.sync();
This will cause the resulting HTTP POST to be,
Started POST "/books" for 127.0.0.1 ...
Processing by BooksController#create as JSON
Parameters: { "book" => { "title" => "the illiad", "author" => "homer", "id" => 1 } }
Branches
master:
- Backbone 1.1.0
- Underscore 1.5.2
1-0-stable
- Backbone 1.0.0
- Underscore 1.5.1
Rails Setup
Install
Add this line to Gemfile,
gem 'railsy_backbone'
And then,
$ bundle install
$ rails g backbone:install
This requires Backbone, Underscore, and the Backbone modifications to implement
the Rails authenticity token and nesting model attributes in the paramsRoot
(see Javscript files with the railsy_backbone. prefix for details).
These will be added to your app/assets/javascripts/application.js:
I value clear communication (I'm serious!). If you think something is missing in the docs, please open a GitHub issue (create issues here), and I'd love to add it if it makes sense.
railsy_backbone
A clone of codebrew/backbone-rails with updated Backbone, Underscore, and jquery-rails versions.
Provides Backbone & Underscore files and modifies Backbone to:
- include the Rails authenticity token in HTTP requests
- nest model attributes within the declared
paramRoot
, EG,This will cause the resulting HTTP POST to be,
Branches
master:
- Backbone 1.1.0
- Underscore 1.5.2
1-0-stable
- Backbone 1.0.0
- Underscore 1.5.1
Rails Setup
Install
Add this line to Gemfile,
And then,
This requires Backbone, Underscore, and the Backbone modifications to implement the Rails authenticity token and nesting model attributes in the paramsRoot (see Javscript files with the
railsy_backbone.
prefix for details).These will be added to your
app/assets/javascripts/application.js
:Generators
Backbone Model
$ rails g backbone:model
Backbone Router
$ rails g backbone:router
Backbone Scaffold
$ rails g backbone:scaffold
Example Usage
Create new rails app,
Install
railsy_backbone
,Generate a standard Rails scaffold,
Generate a
Backbone
scaffold,Edit
books/index.html
to execute actions through the Backbone scaffold UI rather than routing to different pages.If you're using ERB,
index.html.erb
Or HAML,
index.html.haml
If you're using the default Rails 4 scaffold generators, you'll need to adjust the default JSON show view (IE,
show.json
) to render theid
attribute.Without adjusting the JSON show view, you will be redirected to a "undefined" url after creating an object.
Docs
Link to the docs.
I value clear communication (I'm serious!). If you think something is missing in the docs, please open a GitHub issue (create issues here), and I'd love to add it if it makes sense.
Contributors
These awesome people infused their awesome talent in this project.
Credits
Inspired by and copied from Ryan Fitzgerald's codebrew/backbone-rails.
License
See LICENSE