Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add rails 3.0 support, just copy the files over to the junk drawer

  • Loading branch information...
commit 20e6f1d7bc66cc0b8b848f5c8e424eb27b48a954 1 parent 8245256
@johnbintz johnbintz authored
View
4 README.md
@@ -25,6 +25,10 @@ With pure javascript, the lines would look like `app/assets/javascripts/applicat
//= require underscore
//= require backbone
+### Rails 3.0 generator
+
+In Rails 3.0, you can also vendor Backbone into your public/javascripts directory with `rails g backbone:install`
+
## Versioning
The gem will follow backbone versioning.
View
2  backbone-rails.gemspec
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = ">= 1.3.6"
- s.add_dependency "railties", "~> 3.1.0.beta1"
+ s.add_dependency "rails", ">= 3.0.0"
s.files = Dir.glob("{lib,vendor}/**/*") + %w(MIT-LICENSE README.md)
s.require_path = 'lib'
View
8 lib/backbone-rails.rb
@@ -1,9 +1,11 @@
+require 'rails'
module Backbone
module Rails
-
- class Engine < ::Rails::Engine
+ if ::Rails.version < "3.1"
+ require 'backbone-rails/railtie'
+ else
+ require 'backbone-rails/engine'
end
-
end
end
View
9 lib/backbone-rails/engine.rb
@@ -0,0 +1,9 @@
+require 'rails'
+
+module Backbone
+ module Rails
+ class Engine < ::Rails::Engine
+ end
+ end
+end
+
View
19 lib/backbone-rails/generators.rb
@@ -0,0 +1,19 @@
+require 'rails/generators'
+
+module Backbone
+ class Install < ::Rails::Generators::Base
+ JAVASCRIPTS = File.expand_path('../../../vendor/assets/javascripts', __FILE__)
+
+ def self.source_root
+ @source_root ||= JAVASCRIPTS
+ end
+
+ def copy_backbone
+ Dir[File.join(JAVASCRIPTS, '*.js')].each do |file|
+ file = File.split(file).last
+ copy_file file, "public/javascripts/#{file}"
+ end
+ end
+ end
+end
+
View
12 lib/backbone-rails/railtie.rb
@@ -0,0 +1,12 @@
+require 'rails'
+
+module Backbone
+ module Rails
+ class Railtie < ::Rails::Railtie
+ generators do
+ require 'backbone-rails/generators'
+ end
+ end
+ end
+end
+

0 comments on commit 20e6f1d

Please sign in to comment.
Something went wrong with that request. Please try again.