From c6a18308eff836f25a99164d814d02576fe9415a Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Wed, 29 Aug 2007 03:01:11 +0000 Subject: Only reload routes.rb if its been modified. [Dreamer3] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7369 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/routing.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller') 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) -- cgit v1.2.3