From 9a17416d8bda0df0a6961e547c3cf1d677e66b5e Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Thu, 4 Mar 2010 21:59:42 -0800 Subject: Tweak out url_for uses :script_name and add some tests --- actionpack/lib/action_dispatch/routing/route_set.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'actionpack/lib/action_dispatch/routing/route_set.rb') diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 26189329c2..a53d8067dd 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -209,29 +209,27 @@ module ActionDispatch end end - attr_accessor :routes, :named_routes + attr_accessor :routes, :named_routes, :mount_point attr_accessor :disable_clear_and_finalize, :resources_path_names - attr_accessor :script_name def self.default_resources_path_names { :new => 'new', :edit => 'edit' } end - def initialize + def initialize(options = {}) self.routes = [] self.named_routes = NamedRouteCollection.new self.resources_path_names = self.class.default_resources_path_names.dup self.controller_namespaces = Set.new + self.mount_point = options[:mount_point] @disable_clear_and_finalize = false clear! end - def draw(options = {}, &block) + def draw(&block) clear! unless @disable_clear_and_finalize - @script_name = options[:script_name] - mapper = Mapper.new(self) if block.arity == 1 mapper.instance_exec(DeprecatedMapper.new(self), &block) @@ -341,6 +339,7 @@ module ActionDispatch def generate(options, recall = {}, method = :generate) options, recall = options.dup, recall.dup + script_name = options.delete(:script_name) || mount_point named_route = options.delete(:use_route) options = options_as_params(options) @@ -406,6 +405,7 @@ module ActionDispatch [path, params.keys] elsif path path << "?#{params.to_query}" if params.any? + path = "#{script_name}#{path}" path else raise ActionController::RoutingError, "No route matches #{options.inspect}" -- cgit v1.2.3