Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
e22a3d89
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,发现更多精彩内容 >>
提交
e22a3d89
编写于
5月 23, 2009
作者:
Y
Yehuda Katz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Slightly modify things to get content type matching working without breaking other code
上级
3ac6d8f8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
52 addition
and
14 deletion
+52
-14
actionpack/lib/action_controller/abstract/base.rb
actionpack/lib/action_controller/abstract/base.rb
+3
-3
actionpack/lib/action_controller/abstract/layouts.rb
actionpack/lib/action_controller/abstract/layouts.rb
+8
-8
actionpack/lib/action_dispatch/http/request.rb
actionpack/lib/action_dispatch/http/request.rb
+8
-2
actionpack/test/fixtures/test/greeting.html.erb
actionpack/test/fixtures/test/greeting.html.erb
+0
-0
actionpack/test/new_base/render_layout_test.rb
actionpack/test/new_base/render_layout_test.rb
+32
-0
actionpack/test/new_base/test_helper.rb
actionpack/test/new_base/test_helper.rb
+1
-1
未找到文件。
actionpack/lib/action_controller/abstract/base.rb
浏览文件 @
e22a3d89
...
...
@@ -68,11 +68,11 @@ def initialize
self
.
response_obj
=
{}
end
def
process
(
action
_name
)
@_action_name
=
action_name
=
action
_name
.
to_s
def
process
(
action
)
@_action_name
=
action_name
=
action
.
to_s
unless
action_name
=
method_for_action
(
action_name
)
raise
ActionNotFound
,
"The action '
#{
action
_name
}
' could not be found"
raise
ActionNotFound
,
"The action '
#{
action
}
' could not be found"
end
process_action
(
action_name
)
...
...
actionpack/lib/action_controller/abstract/layouts.rb
浏览文件 @
e22a3d89
...
...
@@ -39,15 +39,15 @@ def _implied_layout_name
def
_write_layout_method
case
@_layout
when
String
self
.
class_eval
%{def _layout() #{@_layout.inspect} end}
self
.
class_eval
%{def _layout(
details
) #{@_layout.inspect} end}
when
Symbol
self
.
class_eval
%{def _layout() #{@_layout} end}
self
.
class_eval
%{def _layout(
details
) #{@_layout} end}
when
false
self
.
class_eval
%{def _layout() end}
self
.
class_eval
%{def _layout(
details
) end}
else
self
.
class_eval
%{
def _layout
if view_paths.find_by_parts?("#{_implied_layout_name}",
{:formats => formats}
, "layouts")
def _layout
(details)
if view_paths.find_by_parts?("#{_implied_layout_name}",
details
, "layouts")
"#{_implied_layout_name}"
else
super
...
...
@@ -60,7 +60,7 @@ def _layout
private
def
_layout
()
end
# This will be overwritten
def
_layout
(
details
)
end
# This will be overwritten
# :api: plugin
# ====
...
...
@@ -79,13 +79,13 @@ def _layout_prefix(name)
end
def
_default_layout
(
require_layout
=
false
,
details
=
{
:formats
=>
formats
})
if
require_layout
&&
_action_has_layout?
&&
!
_layout
if
require_layout
&&
_action_has_layout?
&&
!
_layout
(
details
)
raise
ArgumentError
,
"There was no default layout for
#{
self
.
class
}
in
#{
view_paths
.
inspect
}
"
end
begin
_layout_for_name
(
_layout
,
details
)
if
_action_has_layout?
_layout_for_name
(
_layout
(
details
)
,
details
)
if
_action_has_layout?
rescue
NameError
=>
e
raise
NoMethodError
,
"You specified
#{
@_layout
.
inspect
}
as the layout, but no such method was found"
...
...
actionpack/lib/action_dispatch/http/request.rb
浏览文件 @
e22a3d89
...
...
@@ -173,9 +173,15 @@ def format(view_path = [])
def
formats
if
ActionController
::
Base
.
use_accept_header
Array
(
Mime
[
parameters
[
:format
]]
||
accepts
)
ret
=
Array
(
Mime
[
parameters
[
:format
]]
||
accepts
)
if
defined?
(
ActionController
::
Http
)
if
all
=
ret
.
index
(
Mime
::
ALL
)
ret
.
delete
(
Mime
::
ALL
)
&&
ret
.
insert
(
all
,
*
Mime
::
SET
)
end
end
ret
else
[
format
,
Mime
[
:all
]]
[
format
]
+
Mime
::
SET
end
end
...
...
actionpack/test/fixtures/test/greeting.erb
→
actionpack/test/fixtures/test/greeting.
html.
erb
浏览文件 @
e22a3d89
文件已移动
actionpack/test/new_base/render_layout_test.rb
浏览文件 @
e22a3d89
...
...
@@ -66,4 +66,36 @@ class LayoutOptionsTest < SimpleRouteCase
assert_response
"hai(layout_false.html.erb)"
end
end
class
MismatchFormatController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
"layouts/application.html.erb"
=>
"<html><%= yield %></html>"
,
"controller_layouts/mismatch_format/index.js.rjs"
=>
"page[:test].omg"
,
"controller_layouts/mismatch_format/implicit.rjs"
=>
"page[:test].omg"
)]
def
explicit
render
:layout
=>
"application"
end
end
class
MismatchFormatTest
<
SimpleRouteCase
testing
ControllerLayouts
::
MismatchFormatController
test
"if JS is selected, an HTML template is not also selected"
do
get
:index
assert_response
"$(
\"
test
\"
).omg();"
end
test
"if JS is implicitly selected, an HTML template is not also selected"
do
get
:implicit
assert_response
"$(
\"
test
\"
).omg();"
end
test
"if an HTML template is explicitly provides for a JS template, an error is raised"
do
assert_raises
ActionView
::
MissingTemplate
do
get
:explicit
,
{},
"action_dispatch.show_exceptions"
=>
false
end
end
end
end
\ No newline at end of file
actionpack/test/new_base/test_helper.rb
浏览文件 @
e22a3d89
...
...
@@ -67,7 +67,7 @@ def self.testing(klass = nil)
def
get
(
thing
,
*
args
)
if
thing
.
is_a?
(
Symbol
)
super
(
"
#{
self
.
class
.
testing
}
/
#{
thing
}
"
)
super
(
"
#{
self
.
class
.
testing
}
/
#{
thing
}
"
,
*
args
)
else
super
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录