Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

assert that the environment is initialized under rails 3.1.1 (rc3 and…

… up, does not function under rc2)
  • Loading branch information...
commit 5b28cd9df93f2ed78533427452a7421156a5c276 1 parent 97d5c24
@mjtko mjtko authored
Showing with 10 additions and 1 deletion.
  1. +1 −1  app/assets/javascripts/js-routes.js.erb
  2. +9 −0 lib/js_routes.rb
View
2  app/assets/javascripts/js-routes.js.erb
@@ -1 +1 @@
-<%= JsRoutes.generate %>
+<%= JsRoutes.assert_usable_configuration! && JsRoutes.generate %>
View
9 lib/js_routes.rb
@@ -47,6 +47,15 @@ def generate(opts = {})
def generate!(opts = {})
new(opts).generate!
end
+
+ # Under rails 3.1.1 and higher, perform a check to ensure that the
+ # full environment will be available during asset compilation.
+ # This is required to ensure routes are loaded.
+ def assert_usable_configuration!
+ @usable_configuration ||= Rails.version >= "3.1.1" &&
+ Rails.application.config.assets.initialize_on_precompile ||
+ raise("Cannot precompile js-routes unless environment is initialized. Please set config.assets.initialize_on_precompile to true.")
+ end
end
#
Please sign in to comment.
Something went wrong with that request. Please try again.