aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-08-29 03:01:11 +0000
committerMichael Koziarski <michael@koziarski.com>2007-08-29 03:01:11 +0000
commitc6a18308eff836f25a99164d814d02576fe9415a (patch)
tree557e27c0e5f3fc8bfec608587605d8c2bd481428 /actionpack/lib
parent18a3333a30b406633e2bb6fa5b87ada25ce7571d (diff)
downloadrails-c6a18308eff836f25a99164d814d02576fe9415a.tar.gz
rails-c6a18308eff836f25a99164d814d02576fe9415a.tar.bz2
rails-c6a18308eff836f25a99164d814d02576fe9415a.zip
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
Diffstat (limited to 'actionpack/lib')
-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)