I have a class in my /lib/ directory called tracker.rb
It's function is to receive an array of URLs and then perform 4
separate tasks on each URL
Each of the 4 tasks gets it's own thread.
the class is called from my controller like:
output = Tracker.go([array_of_urls])
Sometimes, when it hits an exception, instead of just dieing
gracefully, my logs repeatedly display:
I bet if you switched to production mode it would work. What I think
is happening is:
- request calls Tracker.go
- Rails unloads loaded classes (since we're in dev mode)
- You threads continue to run trying to use classes that rails has
unloaded. Chaos ensues.
I bet if you switched to production mode it would work. What I think
is happening is:
- request calls Tracker.go
- Rails unloads loaded classes (since we're in dev mode)
- You threads continue to run trying to use classes that rails has
unloaded. Chaos ensues.
Fred
Bingo! Putting my application in production mode allowed me to make
continual requests. It, however, doesn't solve the problem though.
Problem:
I've got a module (AccessControl) in RAILS_ROOT/lib that extends my
controllers (which inherit from ResourceController) and adds
functionality to AuthenticatedSystem. In development mode, this works
fine via requests through the browser. However, once I try to consume
the resources with ActiveResource, the first request succeeds and the
next request fails with the following error:
ArgumentError (A copy of AccessControl has been removed from the module
tree but is still active!):
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:250:in
`load_missing_constant'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:468:in
`const_missing'
/lib/access_control.rb:122:in `controller_target'
...
I can't figure out why this would work via the browser but not through
ActiveResource. The only thing that's different, if I understand it
correctly, are the headers:
Accept: application/xml
Content-Type: application/xml
Why would that make a difference? Not only that, the error is
originating in the class it says it can't find. Does anyone understand
why this might be the case?
Frederick Cheung wrote:
> I bet if you switched to production mode it would work. What I think
> is happening is:
> - request calls Tracker.go
> - Rails unloads loaded classes (since we're in dev mode)
> - You threads continue to run trying to use classes that rails has
> unloaded. Chaos ensues.
> Fred
Bingo! Putting my application in production mode allowed me to make
continual requests. It, however, doesn't solve the problem though.
Sorry, forgot to mention. You need to restart the server after modifying
the config file (and will have to restart it every time you make any
changes to your classes, too).