aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/route_set.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-12-14 16:51:13 -0600
committerJoshua Peek <josh@joshpeek.com>2009-12-14 16:51:13 -0600
commitec99eca013ce96fa1fa628510038a9eafa46d3c5 (patch)
treeacc299e0fe3fcaa04268b875e4ef4fe3b9bbc6cf /actionpack/lib/action_dispatch/routing/route_set.rb
parent70c3e825fc184c7267d226c7b365af4db17f58b7 (diff)
downloadrails-ec99eca013ce96fa1fa628510038a9eafa46d3c5.tar.gz
rails-ec99eca013ce96fa1fa628510038a9eafa46d3c5.tar.bz2
rails-ec99eca013ce96fa1fa628510038a9eafa46d3c5.zip
Fix loading plugin and engine route sets
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/route_set.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb25
1 files changed, 20 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 8afd42a293..6f35e9b4e3 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -212,11 +212,14 @@ module ActionDispatch
self.routes = []
self.named_routes = NamedRouteCollection.new
+ @clear_before_draw = true
+ @finalize_set_on_draw = true
+
clear!
end
def draw(&block)
- clear!
+ clear! if @clear_before_draw
mapper = Mapper.new(self)
if block.arity == 1
@@ -225,9 +228,13 @@ module ActionDispatch
mapper.instance_exec(&block)
end
- @set.add_route(NotFound)
- install_helpers
- @set.freeze
+ if @finalize_set_on_draw
+ @set.add_route(NotFound)
+ install_helpers
+ @set.freeze
+ end
+
+ nil
end
def clear!
@@ -283,7 +290,15 @@ module ActionDispatch
def load_routes!
if configuration_files.any?
- configuration_files.each { |config| load(config) }
+ @finalize_set_on_draw = false
+ configuration_files.each_with_index do |config, index|
+ @finalize_set_on_draw = true if index == (configuration_files.length - 1)
+ load(config)
+ @clear_before_draw = false if index == 0
+ end
+ @clear_before_draw = true
+ @finalize_set_on_draw = true
+
@routes_last_modified = routes_changed_at
else
draw do |map|