Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
03be2709
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,发现更多精彩内容 >>
提交
03be2709
编写于
6月 08, 2010
作者:
D
David Heinemeier Hansson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "Add shallow routes to the new router" for now. Needs more work.
This reverts commit
67a60ee3
.
上级
0e9b9d59
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
3 addition
and
75 deletion
+3
-75
actionpack/CHANGELOG
actionpack/CHANGELOG
+0
-10
actionpack/lib/action_dispatch/routing/mapper.rb
actionpack/lib/action_dispatch/routing/mapper.rb
+3
-26
actionpack/test/dispatch/routing_test.rb
actionpack/test/dispatch/routing_test.rb
+0
-39
未找到文件。
actionpack/CHANGELOG
浏览文件 @
03be2709
*
Rails
3.0.0
[
beta
4
]
(
June
8
th
,
2010
)*
*
Add
shallow
routes
back
to
the
new
router
[
Diego
Carrion
]
resources
:
posts
do
shallow
do
resources
:
comments
end
end
You
can
now
use
comment_path
for
/
comments
/
1
instead
of
post_comment_path
for
/
posts
/
1
/
comments
/
1.
*
Remove
middleware
laziness
[
Jos
é
Valim
]
*
Make
session
stores
rely
on
request
.
cookie_jar
and
change
set_session
semantics
to
return
the
cookie
value
instead
of
a
boolean
.
[
Jos
é
Valim
]
...
...
actionpack/lib/action_dispatch/routing/mapper.rb
浏览文件 @
03be2709
...
...
@@ -350,10 +350,6 @@ def constraints(constraints = {})
scope
(
:constraints
=>
constraints
)
{
yield
}
end
def
shallow
scope
(
:shallow
=>
true
)
{
yield
}
end
def
defaults
(
defaults
=
{})
scope
(
:defaults
=>
defaults
)
{
yield
}
end
...
...
@@ -378,21 +374,12 @@ def scope_options
@scope_options
||=
private_methods
.
grep
(
/^merge_(.+)_scope$/
)
{
$1
.
to_sym
}
end
def
merge_shallow_scope
(
parent
,
child
)
parent
or
child
end
def
merge_path_scope
(
parent
,
child
)
parent_path
=
(
@scope
[
:shallow
]
and
child
.
eql?
(
':id'
))
?
parent
.
split
(
'/'
).
last
:
parent
Mapper
.
normalize_path
"
#{
parent_path
}
/
#{
child
}
"
Mapper
.
normalize_path
(
"
#{
parent
}
/
#{
child
}
"
)
end
def
merge_name_prefix_scope
(
parent
,
child
)
if
@scope
[
:shallow
]
child
else
parent
?
"
#{
parent
}
_
#{
child
}
"
:
child
end
parent
?
"
#{
parent
}
_
#{
child
}
"
:
child
end
def
merge_module_scope
(
parent
,
child
)
...
...
@@ -535,10 +522,6 @@ def nested_options
options
[
"
#{
singular
}
_id"
.
to_sym
]
=
id_constraint
if
id_constraint?
options
end
def
shallow?
options
[
:shallow
]
end
end
class
SingletonResource
<
Resource
#:nodoc:
...
...
@@ -620,12 +603,8 @@ def resources(*resources, &block)
resource
=
Resource
.
new
(
resources
.
pop
,
options
)
scope
(
:path
=>
resource
.
path
,
:controller
=>
resource
.
controller
,
:shallow
=>
resource
.
shallow?
)
do
scope
(
:path
=>
resource
.
path
,
:controller
=>
resource
.
controller
)
do
with_scope_level
(
:resources
,
resource
)
do
if
@scope
[
:shallow
]
&&
@scope
[
:name_prefix
]
@scope
[
:path
]
=
"/
#{
@scope
[
:name_prefix
].
pluralize
}
/:
#{
@scope
[
:name_prefix
]
}
_id/
#{
resource
.
path
}
"
end
yield
if
block_given?
with_scope_level
(
:collection
)
do
...
...
@@ -639,8 +618,6 @@ def resources(*resources, &block)
with_scope_level
(
:member
)
do
scope
(
':id'
)
do
scope
(
resource
.
options
)
do
@scope
[
:name_prefix
]
=
nil
if
@scope
[
:shallow
]
get
:show
if
resource
.
actions
.
include?
(
:show
)
put
:update
if
resource
.
actions
.
include?
(
:update
)
delete
:destroy
if
resource
.
actions
.
include?
(
:destroy
)
...
...
actionpack/test/dispatch/routing_test.rb
浏览文件 @
03be2709
...
...
@@ -34,33 +34,6 @@ def self.matches?(request)
end
end
resources
:users
do
shallow
do
resources
:photos
do
resources
:types
do
member
do
post
:preview
end
collection
do
delete
:erase
end
end
end
end
end
shallow
do
resources
:teams
do
resources
:players
end
resources
:countries
do
resources
:cities
do
resources
:places
end
end
end
match
'account/logout'
=>
redirect
(
"/logout"
),
:as
=>
:logout_redirect
match
'account/login'
,
:to
=>
redirect
(
"/login"
)
...
...
@@ -779,18 +752,6 @@ def test_update_person_route
end
end
def
test_shallow_routes
with_test_routes
do
assert_equal
'/photos/4'
,
photo_path
(
4
)
assert_equal
'/types/10/edit'
,
edit_type_path
(
10
)
assert_equal
'/types/5/preview'
,
preview_type_path
(
5
)
assert_equal
'/photos/2/types'
,
photo_types_path
(
2
)
assert_equal
'/cities/1/places'
,
url_for
(
:controller
=>
:places
,
:action
=>
:index
,
:city_id
=>
1
,
:only_path
=>
true
)
assert_equal
'/teams/new'
,
url_for
(
:controller
=>
:teams
,
:action
=>
:new
,
:only_path
=>
true
)
assert_equal
'/photos/11/types/erase'
,
url_for
(
:controller
=>
:types
,
:action
=>
:erase
,
:photo_id
=>
11
,
:only_path
=>
true
)
end
end
def
test_update_project_person
with_test_routes
do
get
'/projects/1/people/2/update'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录