3

I've included the arbor-rails gem in my Rails 3.2.8 application and it works fine in development mode, but in production I get the following error:

Started GET "/nullarbor.js" for 127.0.0.1 at 2012-09-20 15:35:23 -0700

ActionController::RoutingError (No route matches [GET] "/nullarbor.js"):
  actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call'
  railties (3.2.8) lib/rails/engine.rb:479:in `call'
  railties (3.2.8) lib/rails/application.rb:223:in `call'
  rack (1.4.1) lib/rack/content_length.rb:14:in `call'
  railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in `call'
  thin (1.4.1) lib/thin/connection.rb:80:in `block in pre_process'
  thin (1.4.1) lib/thin/connection.rb:78:in `catch'
  thin (1.4.1) lib/thin/connection.rb:78:in `pre_process'
  thin (1.4.1) lib/thin/connection.rb:53:in `process'
  thin (1.4.1) lib/thin/connection.rb:38:in `receive_data'
  eventmachine (1.0.0) lib/eventmachine.rb:187:in `run_machine'
  eventmachine (1.0.0) lib/eventmachine.rb:187:in `run'
  thin (1.4.1) lib/thin/backends/base.rb:63:in `start'
  thin (1.4.1) lib/thin/server.rb:159:in `start'
  rack (1.4.1) lib/rack/handler/thin.rb:13:in `run'
  rack (1.4.1) lib/rack/server.rb:265:in `start'
  railties (3.2.8) lib/rails/commands/server.rb:70:in `start'
  railties (3.2.8) lib/rails/commands.rb:55:in `block in <top (required)>'
  railties (3.2.8) lib/rails/commands.rb:50:in `tap'
  railties (3.2.8) lib/rails/commands.rb:50:in `<top (required)>'
  script/rails:6:in `require'
  script/rails:6:in `<main>'

I've gone through the settings in environments/ and discovered that when I set the following in development.rb:

config.assets.debug = false

I get the error in dev mode, too. And when I set it to true in production it works properly. What could be causing this?

Update: It seems to actually be something to do with the arbor_path function in arbor.js.

lobati
  • 9,284
  • 5
  • 40
  • 61

2 Answers2

3

arbor.js uses a web worker which means that you need to provide the Worker creation with the appropriate link to where the arbor.js script will be.

What you could do to solve this problem is to provide the absolute path to your arbor.js file instead of letting the code use the arbor_path function that can be messed up by your caching logic or the way you serve js files.

In other words, try to replace

i=new Worker(arbor_path()+"arbor.js");

with

i=new Worker("/final/path/to/arbor.js");

in arbor.js

Asimov4
  • 2,776
  • 3
  • 23
  • 38
0

As @Asimov4 stated, the problem is produced on the following call:

new Worker(arbor_path()+"arbor.js");

Nonetheless, a more elegant solution, compatible with the precompilation of assets, is to change it to:

new Worker("<%= asset_path('arbor.js') %>");

Note: Remember to change the .js file to .js.erb!

istern
  • 99
  • 5