Permalink
Browse files

Rails 3.2 compat

  • Loading branch information...
1 parent 709bd35 commit bab6881a01544441b023d37817bc2ed59695e97b @maccman committed Apr 22, 2012
Showing with 14 additions and 2 deletions.
  1. +5 −0 lib/rails/init.rb
  2. +9 −2 lib/sprockets/commonjs.rb
View
5 lib/rails/init.rb
@@ -0,0 +1,5 @@
+puts 'LOADED'
+
+# Rails 3.2.3 compatibility
+Rails.application.assets.register_preprocessor 'application/javascript', Sprockets::CommonJS
+Rails.application.assets.append_path File.expand_path('..', __FILE__)
View
11 lib/sprockets/commonjs.rb
@@ -33,6 +33,13 @@ def evaluate(scope, locals, &block)
end
end
- register_postprocessor 'application/javascript', CommonJS
- append_path File.expand_path('../..', __FILE__)
+ # These methods are not available in older versions of Sprockets
+
+ if respond_to?(:register_postprocessor)
+ register_postprocessor 'application/javascript', CommonJS
+ end
+
+ if respond_to?(:append_path)
+ append_path File.expand_path('../..', __FILE__)
+ end
end

0 comments on commit bab6881

Please sign in to comment.