diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-23 15:05:13 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-23 16:06:33 +0100 |
commit | 80130d1201c3bf9dc17b0e1fcd81c6b22e893b0a (patch) | |
tree | 993d70e97ada23d2860969b24befbde64bd82e4b /actionpack | |
parent | 4eab3aad8d256b868390b739b075bd38661339b2 (diff) | |
download | rails-80130d1201c3bf9dc17b0e1fcd81c6b22e893b0a.tar.gz rails-80130d1201c3bf9dc17b0e1fcd81c6b22e893b0a.tar.bz2 rails-80130d1201c3bf9dc17b0e1fcd81c6b22e893b0a.zip |
Extract routes reloading responsibilities from application and load them just upon a request.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/callbacks.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/railtie.rb | 16 |
2 files changed, 5 insertions, 13 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/callbacks.rb b/actionpack/lib/action_dispatch/middleware/callbacks.rb index d07841218a..7cf75ffe63 100644 --- a/actionpack/lib/action_dispatch/middleware/callbacks.rb +++ b/actionpack/lib/action_dispatch/middleware/callbacks.rb @@ -37,7 +37,7 @@ module ActionDispatch def initialize(app, prepare_each_request = false) @app, @prepare_each_request = app, prepare_each_request - run_callbacks(:prepare) + run_callbacks(:prepare) unless @prepare_each_request end def call(env) diff --git a/actionpack/lib/action_dispatch/railtie.rb b/actionpack/lib/action_dispatch/railtie.rb index e4bd143e78..bd15ca9b3b 100644 --- a/actionpack/lib/action_dispatch/railtie.rb +++ b/actionpack/lib/action_dispatch/railtie.rb @@ -5,22 +5,14 @@ module ActionDispatch class Railtie < Rails::Railtie plugin_name :action_dispatch + # Initialize route files to an array + config.action_dispatch.route_files = [] + # Prepare dispatcher callbacks and run 'prepare' callbacks initializer "action_dispatch.prepare_dispatcher" do |app| # TODO: This used to say unless defined?(Dispatcher). Find out why and fix. require 'rails/dispatcher' - - unless app.config.cache_classes - # Setup dev mode route reloading - routes_last_modified = app.routes_changed_at - reload_routes = lambda do - unless app.routes_changed_at == routes_last_modified - routes_last_modified = app.routes_changed_at - app.reload_routes! - end - end - ActionDispatch::Callbacks.before { |callbacks| reload_routes.call } - end + ActionDispatch::Callbacks.to_prepare { app.routes_reloader.reload_if_changed } end end end
\ No newline at end of file |