Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
43ce6e22
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
43ce6e22
编写于
8月 13, 2014
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ask the scope object if it is a resource_method_scope
上级
e4cb3819
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
10 deletion
+13
-10
actionpack/lib/action_dispatch/routing/mapper.rb
actionpack/lib/action_dispatch/routing/mapper.rb
+13
-10
未找到文件。
actionpack/lib/action_dispatch/routing/mapper.rb
浏览文件 @
43ce6e22
...
...
@@ -1046,7 +1046,6 @@ module Resources
VALID_ON_OPTIONS
=
[
:new
,
:collection
,
:member
]
RESOURCE_OPTIONS
=
[
:as
,
:controller
,
:path
,
:only
,
:except
,
:param
,
:concerns
]
CANONICAL_ACTIONS
=
%w(index create new show update destroy)
RESOURCE_METHOD_SCOPES
=
[
:collection
,
:member
,
:new
]
class
Resource
#:nodoc:
attr_reader
:controller
,
:path
,
:options
,
:param
...
...
@@ -1633,8 +1632,8 @@ def resource_scope? #:nodoc:
@scope
.
resource_scope?
end
def
resource_method_scope?
(
scope_level
)
#:nodoc:
RESOURCE_METHOD_SCOPES
.
include?
scope_level
def
resource_method_scope?
#:nodoc:
@scope
.
resource_method_scope?
end
def
nested_scope?
#:nodoc:
...
...
@@ -1698,8 +1697,8 @@ def param_constraint #:nodoc:
@scope
[
:constraints
][
parent_resource
.
param
]
end
def
canonical_action?
(
action
,
scope_level
)
#:nodoc:
scope_level
&&
resource_method_scope?
(
scope_level
)
&&
CANONICAL_ACTIONS
.
include?
(
action
.
to_s
)
def
canonical_action?
(
action
)
#:nodoc:
resource_method_scope?
&&
CANONICAL_ACTIONS
.
include?
(
action
.
to_s
)
end
def
shallow_scope
(
path
,
options
=
{})
#:nodoc:
...
...
@@ -1713,7 +1712,7 @@ def shallow_scope(path, options = {}) #:nodoc:
end
def
path_for_action
(
action
,
path
)
#:nodoc:
if
path
.
blank?
&&
canonical_action?
(
action
,
@scope
.
scope_level
)
if
path
.
blank?
&&
canonical_action?
(
action
)
@scope
[
:path
].
to_s
else
"
#{
@scope
[
:path
]
}
/
#{
action_path
(
action
,
path
)
}
"
...
...
@@ -1725,10 +1724,10 @@ def action_path(name, path = nil) #:nodoc:
path
||
@scope
[
:path_names
][
name
]
||
name
.
to_s
end
def
prefix_name_for_action
(
as
,
action
,
scope_level
)
#:nodoc:
def
prefix_name_for_action
(
as
,
action
)
#:nodoc:
if
as
prefix
=
as
elsif
!
canonical_action?
(
action
,
scope_level
)
elsif
!
canonical_action?
(
action
)
prefix
=
action
end
...
...
@@ -1738,8 +1737,7 @@ def prefix_name_for_action(as, action, scope_level) #:nodoc:
end
def
name_for_action
(
as
,
action
)
#:nodoc:
scope_level
=
@scope
.
scope_level
prefix
=
prefix_name_for_action
(
as
,
action
,
scope_level
)
prefix
=
prefix_name_for_action
(
as
,
action
)
name_prefix
=
@scope
[
:as
]
if
parent_resource
...
...
@@ -1887,6 +1885,7 @@ class Scope # :nodoc:
:shallow
,
:blocks
,
:defaults
,
:options
]
RESOURCE_SCOPES
=
[
:resource
,
:resources
]
RESOURCE_METHOD_SCOPES
=
[
:collection
,
:member
,
:new
]
attr_reader
:parent
,
:scope_level
...
...
@@ -1904,6 +1903,10 @@ def resources?
scope_level
==
:resources
end
def
resource_method_scope?
RESOURCE_METHOD_SCOPES
.
include?
scope_level
end
def
action_name
(
name_prefix
,
prefix
,
collection_name
,
member_name
)
case
scope_level
when
:nested
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录