aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_controller/routing.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index f50c085a53..70ef8ab583 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -1217,15 +1217,28 @@ module ActionController
install_helpers
end
- alias reload load!
+ # reload! will always force a reload whereas load checks the timestamp first
+ alias reload! load!
+
+ def reload
+ if @routes_last_modified
+ mtime=File.stat("#{RAILS_ROOT}/config/routes.rb").mtime
+ # if it hasn't been changed, then just return
+ return if mtime == @routes_last_modified
+ # if it has changed then record the new time and fall to the load! below
+ @routes_last_modified=mtime
+ end
+ load!
+ end
def load_routes!
if defined?(RAILS_ROOT) && defined?(::ActionController::Routing::Routes) && self == ::ActionController::Routing::Routes
load File.join("#{RAILS_ROOT}/config/routes.rb")
+ @routes_rb_last_modified=File.stat("#{RAILS_ROOT}/config/routes.rb").mtime
else
add_route ":controller/:action/:id"
end
- end
+ end
def add_route(path, options = {})
route = builder.build(path, options)