diff options
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index e05845a04f..24b04088e6 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -291,10 +291,8 @@ module ActionDispatch resource = SingletonResource.new(resources.pop) if @scope[:scope_level] == :resources - with_scope_level(:member) do - scope(parent_resource.id_segment, :name_prefix => parent_resource.member_name) do - resource(resource.name, options, &block) - end + nested do + resource(resource.name, options, &block) end return self end @@ -329,10 +327,8 @@ module ActionDispatch resource = Resource.new(resources.pop) if @scope[:scope_level] == :resources - with_scope_level(:member) do - scope(parent_resource.id_segment, :name_prefix => parent_resource.member_name) do - resources(resource.name, options, &block) - end + nested do + resources(resource.name, options, &block) end return self end @@ -387,6 +383,18 @@ module ActionDispatch end end + def nested + unless @scope[:scope_level] == :resources + raise ArgumentError, "can't use nested outside resources scope" + end + + with_scope_level(:nested) do + scope(parent_resource.id_segment, :name_prefix => parent_resource.member_name) do + yield + end + end + end + def match(*args) options = args.extract_options! |