diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/observer.rb | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index c10bb9f416..b2e2a117fb 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Add note about how ActiveRecord::Observer classes are initialized in a Rails app. #10980 [fxn] + * MySQL: omit text/blob defaults from the schema instead of using an empty string. #10963 [mdeiters] * belongs_to supports :dependent => :destroy and :delete. #10592 [Jonathan Viney] diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb index cfdeae3592..6e4db637f5 100644 --- a/activerecord/lib/active_record/observer.rb +++ b/activerecord/lib/active_record/observer.rb @@ -125,6 +125,20 @@ module ActiveRecord # # Observers will not be invoked unless you define these in your application configuration. # + # == Loading + # + # Observers register themselves in the model class they observe, since it is the class that + # notifies them of events when they occur. As a side-effect, when an observer is loaded its + # corresponding model class is loaded. + # + # Up to (and including) Rails 2.0.2 observers were instantiated between plugins and + # application initializers. Now observers are loaded after application initializers, + # so observed models can make use of extensions. + # + # If by any chance you are using observed models in the initialization you can still + # load their observers by calling <tt>ModelObserver.instance</tt> before. Observers are + # singletons and that call instantiates and registers them. + # class Observer include Singleton |