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

Changeset 8787

Show
Ignore:
Timestamp:
02/02/08 20:18:18 (7 months ago)
Author:
rick
Message:

Reshuffle load order so that routes and observers are initialized after plugins and app initializers. Closes #10980 [rick, fxn]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r8762 r8787  
    11*SVN* 
     2 
     3* Add note about how ActiveRecord::Observer classes are initialized in a Rails app. #10980 [fxn] 
    24 
    35* MySQL: omit text/blob defaults from the schema instead of using an empty string.  #10963 [mdeiters] 
  • trunk/activerecord/lib/active_record/observer.rb

    r8602 r8787  
    126126  # Observers will not be invoked unless you define these in your application configuration. 
    127127  # 
     128  # == Loading 
     129  # 
     130  # Observers register themselves in the model class they observe, since it is the class that 
     131  # notifies them of events when they occur. As a side-effect, when an observer is loaded its 
     132  # corresponding model class is loaded. 
     133  #  
     134  # Up to (and including) Rails 2.0.2 observers were instantiated between plugins and 
     135  # application initializers. Now observers are loaded after application initializers,  
     136  # so observed models can make use of extensions. 
     137  #  
     138  # If by any chance you are using observed models in the initialization you can still 
     139  # load their observers by calling <tt>ModelObserver.instance</tt> before. Observers are 
     140  # singletons and that call instantiates and registers them. 
     141  # 
    128142  class Observer 
    129143    include Singleton 
  • trunk/railties/CHANGELOG

    r8772 r8787  
    11*SVN* 
     2 
     3* Reshuffle load order so that routes and observers are initialized after plugins and app initializers.  Closes #10980 [rick] 
    24 
    35* Git support for script/generate.  #10690 [ssoroka] 
  • trunk/railties/lib/initializer.rb

    r8638 r8787  
    8888      load_plugins 
    8989 
     90      # the framework is now fully initialized 
     91      after_initialize 
     92 
     93      load_application_initializers 
     94 
     95      # Routing must be initialized after plugins to allow the former to extend the routes 
     96      initialize_routing 
     97 
    9098      # Observers are loaded after plugins in case Observers or observed models are modified by plugins. 
    9199      load_observers 
    92  
    93       # Routing must be initialized after plugins to allow the former to extend the routes 
    94       initialize_routing 
    95  
    96       # the framework is now fully initialized 
    97       after_initialize 
    98  
    99       load_application_initializers 
    100100    end 
    101101