Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
fef5cf92
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,发现更多精彩内容 >>
提交
fef5cf92
编写于
6月 22, 2010
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Deprecate :name_prefix in the new router DSL.
上级
62c4e4d3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
23 deletion
+27
-23
actionpack/CHANGELOG
actionpack/CHANGELOG
+2
-0
actionpack/lib/action_dispatch/routing/mapper.rb
actionpack/lib/action_dispatch/routing/mapper.rb
+22
-20
actionpack/test/dispatch/routing_test.rb
actionpack/test/dispatch/routing_test.rb
+3
-3
未找到文件。
actionpack/CHANGELOG
浏览文件 @
fef5cf92
*
Rails
3.0.0
[
Release
Candidate
]
(
unreleased
)*
*
Deprecate
:
name_prefix
in
the
new
router
DSL
[
Jos
é
Valim
]
*
Add
shallow
routes
back
to
the
new
router
[
Diego
Carrion
,
Andrew
White
]
resources
:
posts
do
...
...
actionpack/lib/action_dispatch/routing/mapper.rb
浏览文件 @
fef5cf92
...
...
@@ -299,6 +299,11 @@ def scope(*args)
options
=
args
.
extract_options!
options
=
options
.
dup
if
name_prefix
=
options
.
delete
(
:name_prefix
)
options
[
:as
]
||=
name_prefix
ActiveSupport
::
Deprecation
.
warn
":name_prefix was deprecated in the new router syntax. Use :as instead."
,
caller
end
case
args
.
first
when
String
options
[
:path
]
=
args
.
first
...
...
@@ -343,7 +348,7 @@ def controller(controller)
def
namespace
(
path
)
path
=
path
.
to_s
scope
(
:path
=>
path
,
:
name_prefix
=>
path
,
:module
=>
path
,
:shallow_path
=>
path
,
:shallow_prefix
=>
path
)
{
yield
}
scope
(
:path
=>
path
,
:
as
=>
path
,
:module
=>
path
,
:shallow_path
=>
path
,
:shallow_prefix
=>
path
)
{
yield
}
end
def
constraints
(
constraints
=
{})
...
...
@@ -359,10 +364,10 @@ def match(*args)
options
=
(
@scope
[
:options
]
||
{}).
merge
(
options
)
if
@scope
[
:
name_prefix
]
&&
!
options
[
:as
].
blank?
options
[
:as
]
=
"
#{
@scope
[
:
name_prefix
]
}
_
#{
options
[
:as
]
}
"
elsif
@scope
[
:
name_prefix
]
&&
options
[
:as
]
==
""
options
[
:as
]
=
@scope
[
:
name_prefix
].
to_s
if
@scope
[
:
as
]
&&
!
options
[
:as
].
blank?
options
[
:as
]
=
"
#{
@scope
[
:
as
]
}
_
#{
options
[
:as
]
}
"
elsif
@scope
[
:
as
]
&&
options
[
:as
]
==
""
options
[
:as
]
=
@scope
[
:
as
].
to_s
end
args
.
push
(
options
)
...
...
@@ -382,7 +387,7 @@ def merge_shallow_path_scope(parent, child)
Mapper
.
normalize_path
(
"
#{
parent
}
/
#{
child
}
"
)
end
def
merge_
name_prefix
_scope
(
parent
,
child
)
def
merge_
as
_scope
(
parent
,
child
)
parent
?
"
#{
parent
}
_
#{
child
}
"
:
child
end
...
...
@@ -435,6 +440,7 @@ def initialize(entities, options = {})
@name
=
entities
.
to_s
@path
=
options
.
delete
(
:path
)
||
@name
@controller
=
options
.
delete
(
:controller
)
||
@name
.
to_s
.
pluralize
@as
=
options
.
delete
(
:as
)
@options
=
options
end
...
...
@@ -453,7 +459,7 @@ def actions
end
def
name
options
[
:as
]
||
@name
@as
||
@name
end
def
plural
...
...
@@ -505,7 +511,7 @@ def nested_path
def
nested_options
{}.
tap
do
|
opts
|
opts
[
:
name_prefix
]
=
member_name
opts
[
:
as
]
=
member_name
opts
[
"
#{
singular
}
_id"
.
to_sym
]
=
id_constraint
if
id_constraint?
opts
[
:options
]
=
{
:shallow
=>
shallow?
}
unless
options
[
:shallow
].
nil?
end
...
...
@@ -537,14 +543,10 @@ def self.default_actions
[
:show
,
:create
,
:update
,
:destroy
,
:new
,
:edit
]
end
def
initialize
(
entity
,
options
=
{})
super
end
def
member_name
name
end
alias
_method
:collection_name
,
:member_name
alias
:collection_name
:member_name
def
nested_path
path
...
...
@@ -552,7 +554,7 @@ def nested_path
def
nested_options
{}.
tap
do
|
opts
|
opts
[
:
name_prefix
]
=
member_name
opts
[
:
as
]
=
member_name
opts
[
:options
]
=
{
:shallow
=>
shallow?
}
unless
@options
[
:shallow
].
nil?
end
end
...
...
@@ -673,7 +675,7 @@ def nested
if
@scope
[
:shallow_path
].
blank?
scope
(
*
parent_resource
.
nested_scope
)
{
yield
}
else
scope
(
@scope
[
:shallow_path
],
:
name_prefix
=>
@scope
[
:shallow_prefix
])
do
scope
(
@scope
[
:shallow_path
],
:
as
=>
@scope
[
:shallow_prefix
])
do
scope
(
*
parent_resource
.
nested_scope
)
{
yield
}
end
end
...
...
@@ -758,7 +760,7 @@ def match(*args)
def
root
(
options
=
{})
if
@scope
[
:scope_level
]
==
:resources
with_scope_level
(
:nested
)
do
scope
(
parent_resource
.
path
,
:
name_prefix
=>
parent_resource
.
collection_name
)
do
scope
(
parent_resource
.
path
,
:
as
=>
parent_resource
.
collection_name
)
do
super
(
options
)
end
end
...
...
@@ -806,14 +808,14 @@ def resource_method_scope?
def
with_exclusive_scope
begin
old_name_prefix
,
old_path
=
@scope
[
:
name_prefix
],
@scope
[
:path
]
@scope
[
:
name_prefix
],
@scope
[
:path
]
=
nil
,
nil
old_name_prefix
,
old_path
=
@scope
[
:
as
],
@scope
[
:path
]
@scope
[
:
as
],
@scope
[
:path
]
=
nil
,
nil
with_scope_level
(
:exclusive
)
do
yield
end
ensure
@scope
[
:
name_prefix
],
@scope
[
:path
]
=
old_name_prefix
,
old_path
@scope
[
:
as
],
@scope
[
:path
]
=
old_name_prefix
,
old_path
end
end
...
...
@@ -908,7 +910,7 @@ def options_for_action(action, options)
end
def
name_for_action
(
action
)
name_prefix
=
@scope
[
:
name_prefix
].
blank?
?
""
:
"
#{
@scope
[
:name_prefix
]
}
_"
name_prefix
=
@scope
[
:
as
].
blank?
?
""
:
"
#{
@scope
[
:as
]
}
_"
shallow_prefix
=
@scope
[
:shallow_prefix
].
blank?
?
""
:
"
#{
@scope
[
:shallow_prefix
]
}
_"
case
action
...
...
actionpack/test/dispatch/routing_test.rb
浏览文件 @
fef5cf92
...
...
@@ -70,7 +70,7 @@ def self.matches?(request)
get
'admin/passwords'
=>
"queenbee#passwords"
,
:constraints
=>
::
TestRoutingMapper
::
IpRestrictor
scope
'pt'
,
:
name_prefix
=>
'pt'
do
scope
'pt'
,
:
as
=>
'pt'
do
resources
:projects
,
:path_names
=>
{
:edit
=>
'editar'
,
:new
=>
'novo'
},
:path
=>
'projetos'
do
post
:preview
,
:on
=>
:new
end
...
...
@@ -243,9 +243,9 @@ def self.matches?(request)
end
controller
:articles
do
scope
'/articles'
,
:
name_prefix
=>
'article'
do
scope
'/articles'
,
:
as
=>
'article'
do
scope
:path
=>
'/:title'
,
:title
=>
/[a-z]+/
,
:as
=>
:with_title
do
match
'/:id'
,
:to
=>
:with_id
match
'/:id'
,
:to
=>
:with_id
,
:as
=>
""
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录