mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Seperate scope level for nesting resources
This commit is contained in:
parent
33658ea1ae
commit
c4df6332a4
1 changed files with 16 additions and 8 deletions
|
@ -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!
|
||||
|
||||
|
|
Loading…
Reference in a new issue