aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2010-01-15 16:12:28 -0600
committerJoshua Peek <josh@joshpeek.com>2010-01-15 16:13:01 -0600
commit6437eb9f351f379d1d32aaabf5d8da9f21d53b0f (patch)
treed97afeb20c4b4067833f5b7aa2b65878de270073 /actionpack
parent576b8dda52b0d0d099f88241ef6f4ec1e1248c3b (diff)
downloadrails-6437eb9f351f379d1d32aaabf5d8da9f21d53b0f.tar.gz
rails-6437eb9f351f379d1d32aaabf5d8da9f21d53b0f.tar.bz2
rails-6437eb9f351f379d1d32aaabf5d8da9f21d53b0f.zip
Always join scoped paths with slashes
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb28
1 files changed, 17 insertions, 11 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 3c13cf88f4..9b8660d22b 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -68,7 +68,7 @@ module ActionDispatch
end
def normalize_path(path)
- path = "#{@scope[:path]}#{path}"
+ path = "#{@scope[:path]}/#{path}"
raise ArgumentError, "path is required" if path.empty?
Mapper.normalize_path(path)
end
@@ -160,7 +160,7 @@ module ActionDispatch
# (:locale) becomes (/:locale) instead of /(:locale).
def self.normalize_path(path)
path = Rack::Mount::Utils.normalize_path(path)
- path.sub!(/^\/\(+\/?:/, '(/:')
+ path.sub!(%r{/\(+/?:}, '(/:')
path
end
@@ -283,7 +283,7 @@ module ActionDispatch
end
def namespace(path)
- scope("/#{path}", :name_prefix => path.to_s, :namespace => path.to_s) { yield }
+ scope(path.to_s, :name_prefix => path.to_s, :namespace => path.to_s) { yield }
end
def constraints(constraints = {})
@@ -311,7 +311,7 @@ module ActionDispatch
end
def merge_path_scope(parent, child)
- Mapper.normalize_path(parent.to_s + child.to_s)
+ Mapper.normalize_path("#{parent}/#{child}")
end
def merge_name_prefix_scope(parent, child)
@@ -440,7 +440,7 @@ module ActionDispatch
return self
end
- scope(:path => "/#{resource.name}", :controller => resource.controller) do
+ scope(:path => resource.name.to_s, :controller => resource.controller) do
with_scope_level(:resource, resource) do
yield if block_given?
@@ -481,7 +481,7 @@ module ActionDispatch
return self
end
- scope(:path => "/#{resource.name}", :controller => resource.controller) do
+ scope(:path => resource.name.to_s, :controller => resource.controller) do
with_scope_level(:resources, resource) do
yield if block_given?
@@ -492,7 +492,7 @@ module ActionDispatch
end
with_scope_level(:member) do
- scope("/:id") do
+ scope(':id') do
get :show, :as => resource.member_name if resource.actions.include?(:show)
put :update if resource.actions.include?(:update)
delete :destroy if resource.actions.include?(:destroy)
@@ -523,7 +523,7 @@ module ActionDispatch
end
with_scope_level(:member) do
- scope("/:id", :name_prefix => parent_resource.member_name, :as => "") do
+ scope(':id', :name_prefix => parent_resource.member_name, :as => "") do
yield
end
end
@@ -535,7 +535,7 @@ module ActionDispatch
end
with_scope_level(:nested) do
- scope("/#{parent_resource.id_segment}", :name_prefix => parent_resource.member_name) do
+ scope(parent_resource.id_segment, :name_prefix => parent_resource.member_name) do
yield
end
end
@@ -554,10 +554,16 @@ module ActionDispatch
if args.first.is_a?(Symbol)
action = args.first
if CRUD_ACTIONS.include?(action)
- return match("(.:format)", options.reverse_merge(:to => action))
+ begin
+ old_path = @scope[:path]
+ @scope[:path] = "#{@scope[:path]}(.:format)"
+ return match(options.reverse_merge(:to => action))
+ ensure
+ @scope[:path] = old_path
+ end
else
with_exclusive_name_prefix(action) do
- return match("/#{action_path(action, resources_path_names)}(.:format)", options.reverse_merge(:to => action))
+ return match("#{action_path(action, resources_path_names)}(.:format)", options.reverse_merge(:to => action))
end
end
end