diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-12-08 16:06:46 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-12-08 16:06:46 -0600 |
commit | c4df6332a4d8292dd7d6bd6a1badc896a2323d11 (patch) | |
tree | c620922d73d25cf87d937947a4eefa7744f1ab16 /actionpack | |
parent | 33658ea1ae4170f4b0b5123e240d79bb292719e7 (diff) | |
download | rails-c4df6332a4d8292dd7d6bd6a1badc896a2323d11.tar.gz rails-c4df6332a4d8292dd7d6bd6a1badc896a2323d11.tar.bz2 rails-c4df6332a4d8292dd7d6bd6a1badc896a2323d11.zip |
Seperate scope level for nesting resources
Diffstat (limited to 'actionpack')
-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! |