aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/route_set.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2012-12-14 13:50:14 +0000
committerAndrew White <andyw@pixeltrix.co.uk>2012-12-14 13:50:14 +0000
commit6ab1a9540b73555f2cabb54860b9ca17e8f226cb (patch)
treea04eae40253ee837dae4a62c616edc3909483327 /actionpack/lib/action_dispatch/routing/route_set.rb
parent3bf4ddfefbd26a558bda00fbea537db712f9d865 (diff)
downloadrails-6ab1a9540b73555f2cabb54860b9ca17e8f226cb.tar.gz
rails-6ab1a9540b73555f2cabb54860b9ca17e8f226cb.tar.bz2
rails-6ab1a9540b73555f2cabb54860b9ca17e8f226cb.zip
Clear url helper methods when routes are reloaded
Clear url helper methods when routes are reloaded by removing the methods explicitly rather than just clearing the module because it didn't work properly and could be the source of a memory leak. Closes #8488.
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/route_set.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 8168bd4fcc..a993699e05 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -94,7 +94,12 @@ module ActionDispatch
attr_reader :routes, :helpers, :module
def initialize
- clear!
+ @routes = {}
+ @helpers = []
+
+ @module = Module.new do
+ instance_methods.each { |selector| remove_method(selector) }
+ end
end
def helper_names
@@ -102,12 +107,14 @@ module ActionDispatch
end
def clear!
+ @helpers.each do |helper|
+ @module.module_eval do
+ remove_possible_method helper
+ end
+ end
+
@routes = {}
@helpers = []
-
- @module ||= Module.new do
- instance_methods.each { |selector| remove_method(selector) }
- end
end
def add(name, route)
@@ -291,7 +298,6 @@ module ActionDispatch
def clear!
@finalized = false
- @url_helpers = nil
named_routes.clear
set.clear
formatter.clear