Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
80307c8b
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,体验更适合开发者的 AI 搜索 >>
提交
80307c8b
编写于
12月 26, 2008
作者:
P
Pratik Naik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make ActionController#render(symbol) behave same as ActionController#render(string) [#1435]
上级
cd1d6e87
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
16 addition
and
6 deletion
+16
-6
actionpack/CHANGELOG
actionpack/CHANGELOG
+1
-0
actionpack/lib/action_controller/base.rb
actionpack/lib/action_controller/base.rb
+5
-5
actionpack/test/controller/render_test.rb
actionpack/test/controller/render_test.rb
+10
-1
未找到文件。
actionpack/CHANGELOG
浏览文件 @
80307c8b
...
...
@@ -4,6 +4,7 @@
#
Instead
of
render
(:
action
=>
'other_action'
)
render
(
'other_action'
)
#
argument
has
no
'/'
render
(:
other_action
)
#
Instead
of
render
(:
template
=>
'controller/action'
)
render
(
'controller/action'
)
#
argument
must
not
begin
with
a
'/'
,
but
contain
a
'/'
...
...
actionpack/lib/action_controller/base.rb
浏览文件 @
80307c8b
...
...
@@ -859,14 +859,14 @@ def append_view_path(path)
def
render
(
options
=
nil
,
extra_options
=
{},
&
block
)
#:doc:
raise
DoubleRenderError
,
"Can only render or redirect once per action"
if
performed?
validate_render_arguments
(
options
,
extra_options
)
validate_render_arguments
(
options
,
extra_options
,
block_given?
)
if
options
.
nil?
return
render
(
:file
=>
default_template
,
:layout
=>
true
)
elsif
options
==
:update
options
=
extra_options
.
merge
({
:update
=>
true
})
elsif
options
.
is_a?
(
String
)
case
options
.
index
(
'/'
)
elsif
options
.
is_a?
(
String
)
||
options
.
is_a?
(
Symbol
)
case
options
.
to_s
.
index
(
'/'
)
when
0
extra_options
[
:file
]
=
options
when
nil
...
...
@@ -1193,8 +1193,8 @@ def render_for_text(text = nil, status = nil, append_response = false) #:nodoc:
end
end
def
validate_render_arguments
(
options
,
extra_options
)
if
options
&&
options
!=
:update
&&
!
options
.
is_a?
(
String
)
&&
!
options
.
is_a?
(
Hash
)
def
validate_render_arguments
(
options
,
extra_options
,
has_block
)
if
options
&&
(
has_block
&&
options
!=
:update
)
&&
!
options
.
is_a?
(
String
)
&&
!
options
.
is_a?
(
Hash
)
&&
!
options
.
is_a?
(
Symbol
)
raise
RenderError
,
"You called render with invalid options :
#{
options
.
inspect
}
"
end
...
...
actionpack/test/controller/render_test.rb
浏览文件 @
80307c8b
...
...
@@ -304,6 +304,10 @@ def layout_test_with_different_layout_and_string_action
render
"hello_world"
,
:layout
=>
"standard"
end
def
layout_test_with_different_layout_and_symbol_action
render
:hello_world
,
:layout
=>
"standard"
end
def
rendering_without_layout
render
:action
=>
"hello_world"
,
:layout
=>
false
end
...
...
@@ -1057,11 +1061,16 @@ def test_layout_test_with_different_layout
assert_equal
"<html>Hello world!</html>"
,
@response
.
body
end
def
test_layout_test_with_different_layout
def
test_layout_test_with_different_layout
_and_string_action
get
:layout_test_with_different_layout_and_string_action
assert_equal
"<html>Hello world!</html>"
,
@response
.
body
end
def
test_layout_test_with_different_layout_and_symbol_action
get
:layout_test_with_different_layout_and_symbol_action
assert_equal
"<html>Hello world!</html>"
,
@response
.
body
end
def
test_rendering_without_layout
get
:rendering_without_layout
assert_equal
"Hello world!"
,
@response
.
body
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录