I am trying to use web workers to run multiple JavaScript codes at the same time. To start the worker, I put the following in the javascript code section:
var worker = new Worker("my_task.js"); worker.onmessage = function(e) { console.log('Worker said: ', e.data); }; worker.postMessage("test");
my_task.js is the same folder as the file that contains the code above. This is what my_task.js looks like :
self.addEventListener('message', function(e) { self.postMessage(e.data); }, false);
But there seems to be a problem with Ruby on Rails (version 3.2.1):
Started GET "/users/my_task.js" for 127.0.0.1 at ... ... ... ActiveRecord::RecordNotFound (Couldn't find User with id=my_task)
As you can see, Rails tries to send an http get request when the script runs.
How can I solve this problem? Is there a better way to use web workers in Rails projects?
thanks
zobel source share