Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
53919bbf
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,发现更多精彩内容 >>
提交
53919bbf
编写于
1月 19, 2015
作者:
S
Santiago Pastorino
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18483 from rono23/fix-name_for_action-in-routing
Fix name_for_action in routing
上级
0b0e9e83
8a8dac80
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
2 deletion
+41
-2
actionpack/lib/action_dispatch/routing/mapper.rb
actionpack/lib/action_dispatch/routing/mapper.rb
+3
-2
actionpack/test/dispatch/routing_test.rb
actionpack/test/dispatch/routing_test.rb
+38
-0
未找到文件。
actionpack/lib/action_dispatch/routing/mapper.rb
浏览文件 @
53919bbf
...
...
@@ -1739,9 +1739,10 @@ def name_for_action(as, action) #:nodoc:
member_name
=
parent_resource
.
member_name
end
name
=
@scope
.
action_name
(
name_prefix
,
prefix
,
collection_name
,
member_name
)
action_name
=
@scope
.
action_name
(
name_prefix
,
prefix
,
collection_name
,
member_name
)
candidate
=
action_name
.
select
(
&
:present?
).
join
(
'_'
)
if
candidate
=
name
.
compact
.
join
(
"_"
).
presence
unless
candidate
.
empty?
# If a name was not explicitly given, we check if it is valid
# and return nil in case it isn't. Otherwise, we pass the invalid name
# forward so the underlying router engine treats it and raises an exception.
...
...
actionpack/test/dispatch/routing_test.rb
浏览文件 @
53919bbf
...
...
@@ -3439,6 +3439,44 @@ def test_scope_shallow_path_is_not_overwritten_by_path
assert_equal
'/bar/comments/1'
,
comment_path
(
'1'
)
end
def
test_resource_where_as_is_empty
draw
do
resource
:post
,
as:
''
scope
'post'
,
as:
'post'
do
resource
:comment
,
as:
''
end
end
assert_equal
'/post/new'
,
new_path
assert_equal
'/post/comment/new'
,
new_post_path
end
def
test_resources_where_as_is_empty
draw
do
resources
:posts
,
as:
''
scope
'posts'
,
as:
'posts'
do
resources
:comments
,
as:
''
end
end
assert_equal
'/posts/new'
,
new_path
assert_equal
'/posts/comments/new'
,
new_posts_path
end
def
test_scope_where_as_is_empty
draw
do
scope
'post'
,
as:
''
do
resource
:user
resources
:comments
end
end
assert_equal
'/post/user/new'
,
new_user_path
assert_equal
'/post/comments/new'
,
new_comment_path
end
private
def
draw
(
&
block
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录