Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #6942 (new defect)

Opened 3 years ago

Last modified 3 years ago

Reloading breaks Observers in development mode

Reported by: caspercg Assigned to: core
Priority: normal Milestone: 1.2.7
Component: ActiveRecord Version: 1.1.6
Severity: major Keywords: observers activerecord reloading
Cc:

Description

Observers work intermittently in development mode. Specifically with

config.cache_classes = false

in config/environments/development.rb Observers will simply fail to trigger using WEBrick. The whole idea with development mode is having cache_classes = false.

Observers work fine from the console or testing, even in development mode. But do a "reload!" in the console and POOF, Observers are no longer triggered.

This is a very hard bug to track down when it happens. Took me a long time to figure out it was not my code that was broken. This pretty much makes Observers unusable. There's no "agile development" in running with cache_classes = true, just so your code will work during development. Might as well develop in production mode then.

If this bug isn't fixed it at LEAST needs to be mentioned in the docs. It's an invitation to waste people's time not to. Very hard to track down, and you will want to revert all your code once you realize what broke it.

See also: http://dev.rubyonrails.org/ticket/3558 ..issued over a year ago.

Change History

01/08/07 12:11:04 changed by caspercg

  • milestone changed from 1.x to 1.2.

01/24/07 10:45:36 changed by helios9

The easy fix for this in 1.2 is unloadable(ModelObserver). It could be fixed by doing that automatically every time the observer is linked to a class. Before I go and make a patch. I would like to hear why this already is not done.