1

Is there any known way to run the js-routes gem on Heroku? The trouble seems to stem from the fact that the routes can't be compiled when the App isn't mounted (because it needs access to the Rails routes), but Heroku won't let you set initialize_on_precompile = true in order to make that possible. I'd really like to use the gem though... I predict it'll save me a ton of trouble down the line. Any ideas?

1 Answer 1

1

I use workaround. Pre-generate routes in dev env.

Add js routes into development group in Gemfile.

Then fix initializer:

if defined?(JsRoutes)
  JsRoutes.setup do |config|
    config.include = [/item/]
    config.default_url_options = {:locale => I18n.locale}
  end
end

Then run rake js:routes to generate js file. And finally add app/assets/javascripts/routes.js into repo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.