Permalink
Browse files

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
  • Loading branch information...
1 parent 18a3333 commit c6a18308eff836f25a99164d814d02576fe9415a @NZKoz NZKoz committed Aug 29, 2007
Showing with 15 additions and 2 deletions.
  1. +15 −2 actionpack/lib/action_controller/routing.rb
@@ -1217,15 +1217,28 @@ def load!
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)

0 comments on commit c6a1830

Please sign in to comment.