railsware/js-routes — pull request #90 by alexaitken (2013-12-21 17:56:37+00:00)
Title: Correct thread safety issue in js-routes generation

The reloading of routes during generation of js routes cause failures when multiple threads are including js-routes.

Error: RuntimeError: can't add a new key into hash during iteration
(in /Users/alex/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/js-routes-0.9.6/app/assets/javascripts/js-routes.js.erb)

I believe this comes from calling Rails.application.reload_routes! while another thread is iterating the list of routes.

I have created an example application to show the issue. https://github.com/alexaitken/js_routes_failure

I removed the call to Rails.application.reload_routes! entirely. This change passes the tests and corrects the issue in the example application.

I found that the line Rails.application.reload_routes! was added back in commit 3f3dfda55014b868e9e5a1bacaecbe5ace4ce9d4 , but I am not sure what that change was solving. So this change may break something, that is not in the test suite.