Skip to content

Loading…

added a manifest file #89

Closed
wants to merge 3 commits into from

2 participants

@nathanvda

Hi there, thank you for your awesome work.
I am just starting with backbone, so for me it was at first a bit hard to get everything to work, as it was not entirely clear to me how and which files to include in the asset-pipeline.

To make that easier, I included an manifest file rails_backbone so including all needed files just becomes a single file, likeso:

//= require rails_backbone

A developer still has to include her application of course. I also clarified this in the README file.

I also changed a few smaller things:

  • gitignored the rvmrc (each developer can then use her own)
  • I needed to add therubyracer to the Gemfile (I am on ubuntu)

I hope this helps.

@codebrew codebrew closed this
@codebrew
Owner

It sounds like you might be a bit confused with how to use this project.

Inside your existing rails3.1 or greater app, just add gem rails_backbone then do a bundle install and rails g backbone:install. This is all in the readme and sets up everything you need. I decided to not to a manifest file originally because then it prevents people from picking and choosing what libs they want to include.

@nathanvda

Ah right, now I see the problem. I did not have the line

//= require tree

in my application.js. So for me the installer just did not work.

So that is why, when I went looking to your test-project, I saw the missing lines and thought they had to be included manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 43 additions and 52 deletions.
  1. +1 −0 .gitignore
  2. +0 −47 .rvmrc
  3. +1 −0 Gemfile
  4. +4 −0 Gemfile.lock
  5. +20 −1 README.md
  6. +1 −4 test/dummy/app/assets/javascripts/application.js
  7. +16 −0 vendor/assets/javascripts/rails_backbone.js
View
1 .gitignore
@@ -7,3 +7,4 @@ test/dummy/tmp/
test/dummy/.sass-cache/
test/tmp/**/*
.idea/
+.rvmrc
View
47 .rvmrc
@@ -1,47 +0,0 @@
-#!/usr/bin/env bash
-
-# This is an RVM Project .rvmrc file, used to automatically load the ruby
-# development environment upon cd'ing into the directory
-
-# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
-environment_id="ruby-1.9.2-p180@backbone-rails"
-
-#
-# First we attempt to load the desired environment directly from the environment
-# file, this is very fast and efficicent compared to running through the entire
-# CLI and selector. If you want feedback on which environment was used then
-# insert the word 'use' after --create as this triggers verbose mode.
-#
-if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
- && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] ; then
- \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
-else
- # If the environment file has not yet been created, use the RVM CLI to select.
- rvm --create "$environment_id"
-fi
-
-#
-# If you use an RVM gemset file to install a list of gems (*.gems), you can have
-# it be automatically loaded, uncomment the following and adjust the filename if
-# necessary.
-#
-# filename=".gems"
-# if [[ -s "$filename" ]] ; then
-# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
-# fi
-
-#
-# If you use bundler and would like to run bundle each time you enter the
-# directory you can uncomment the following code.
-#
-# Ensure that Bundler is installed, install it if it is not.
-if ! command -v bundle ; then
- printf "The rubygem 'bundler' is not installed, installing it now.\n"
- gem install bundler
-fi
-#
-# # Bundle while redcing excess noise.
-# printf "Bundling your gems this may take a few minutes on a fresh clone.\n"
-# bundle | grep -v 'Using' | grep -v 'complete' | sed '/^$/d'
-#
-
View
1 Gemfile
@@ -24,4 +24,5 @@ group :test do
gem "mocha", ">= 0.9.12"
gem "turn", ">= 0.8.2"
gem "minitest"
+ gem 'therubyracer', :platforms => :ruby
end
View
4 Gemfile.lock
@@ -48,6 +48,7 @@ GEM
railties (>= 3.2.0.beta, < 5.0)
thor (~> 0.14)
json (1.6.5)
+ libv8 (3.3.10.4)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mail (2.4.1)
@@ -102,6 +103,8 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
+ therubyracer (0.9.9)
+ libv8 (~> 3.3.10)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
@@ -127,5 +130,6 @@ DEPENDENCIES
ruby-debug19
sass
sqlite3
+ therubyracer
turn (>= 0.8.2)
uglifier
View
21 README.md
@@ -20,6 +20,19 @@ Then run the following commands:
bundle install
rails g backbone:install
+To include `backbone` into your asset pipeline, add the following line to your `application.js`
+
+ //= require rails_backbone
+ //= require backbone/<your-app-name>
+
+If you want to, you can also include all parts manually:
+
+ //= require underscore
+ //= require backbone
+ //= require backbone_rails_sync
+ //= require backbone_datalink
+ //= require backbone/<your-app-name>
+
### Layout and namespacing
Running `rails g backbone:install` will create the following directory structure under `app/assets/javascripts/backbone`:
@@ -29,7 +42,7 @@ Running `rails g backbone:install` will create the following directory structure
templates/
views/
-It will also create a toplevel app_name.coffee file to setup namespacing and setup initial requires.
+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 backbone.js with rails 3.1 and greater.
@@ -96,6 +109,12 @@ If you prefer haml, this is equivalent to inserting the following code into `app
Backbone.history.start();
});
+
+Do not forget to edit your `app/assets/javascripts/application.js` and add
+
+ //= require rails_backbone
+ //= require backbone/blog
+
Now start your server `rails s` and browse to [localhost:3000/posts](http://localhost:3000/posts)
You should now have a fully functioning single page crud app for Post models.
View
5 test/dummy/app/assets/javascripts/application.js
@@ -3,9 +3,6 @@
//
//= require jquery
//= require jquery_ujs
-//= require underscore
-//= require backbone
-//= require backbone_rails_sync
-//= require backbone_datalink
+//= require rails_backbone
//= require backbone/dummy
//= require_tree .
View
16 vendor/assets/javascripts/rails_backbone.js
@@ -0,0 +1,16 @@
+//
+// For convenience a manifest to include all needed files at one
+// Now you just need to write
+//
+// require rails_backbone
+//
+// in your application.js or
+//
+// javascript_include_tag :rails_backbone
+//
+// If you want to load it on specific pages only.
+//
+//= require underscore
+//= require backbone
+//= require backbone_rails_sync
+//= require backbone_datalink
Something went wrong with that request. Please try again.