Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
f00cbf78
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,发现更多精彩内容 >>
提交
f00cbf78
编写于
1月 19, 2010
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bring render_message back for 2.3 compatibility.
上级
a0374582
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
13 deletion
+33
-13
actionmailer/lib/action_mailer/base.rb
actionmailer/lib/action_mailer/base.rb
+31
-11
actionmailer/test/mail_service_test.rb
actionmailer/test/mail_service_test.rb
+2
-2
未找到文件。
actionmailer/lib/action_mailer/base.rb
浏览文件 @
f00cbf78
...
...
@@ -143,12 +143,13 @@ module ActionMailer #:nodoc:
# subject "New account information"
# from "system@example.com"
# content_type "multipart/alternative"
# body :account => recipient
#
# part :content_type => "text/html",
# :
body => render_message("signup-as-html", :account => recipient
)
# :
data => render_message("signup-as-html"
)
#
# part "text/plain" do |p|
# p.body = render_message("signup-as-plain"
, :account => recipient
)
# p.body = render_message("signup-as-plain")
# p.content_transfer_encoding = "base64"
# end
# end
...
...
@@ -453,11 +454,13 @@ def matches_dynamic_method?(method_name) #:nodoc:
# body, headers, etc.) can be set on it.
def
part
(
params
)
params
=
{
:content_type
=>
params
}
if
String
===
params
if
custom_headers
=
params
.
delete
(
:headers
)
ActiveSupport
::
Deprecation
.
warn
(
'Passing custom headers with :headers => {} is deprecated. '
<<
'Please just pass in custom headers directly.'
,
caller
[
0
,
10
])
params
.
merge!
(
custom_headers
)
end
part
=
Mail
::
Part
.
new
(
params
)
yield
part
if
block_given?
@parts
<<
part
...
...
@@ -475,6 +478,20 @@ def attachment(params, &block)
part
(
params
,
&
block
)
end
# Allow you to set assigns for your template:
#
# body :greetings => "Hi"
#
# Will make @greetings available in the template to be rendered.
def
body
(
object
=
nil
)
returning
(
super
)
do
# Run deprecation hooks
if
object
.
is_a?
(
Hash
)
@assigns_set
=
true
object
.
each
{
|
k
,
v
|
instance_variable_set
(
:"@
#{
k
}
"
,
v
)
}
end
end
end
# Instantiate a new mailer object. If +method_name+ is not +nil+, the mailer
# will be initialized according to the named method. If not, the mailer will
# remain uninitialized (useful when you only need to invoke the "receive"
...
...
@@ -522,17 +539,20 @@ def deliver!(mail = @mail)
private
# Allow you to set assigns for your template:
# Render a message but does not set it as mail body. Useful for rendering
# data for part and attachments.
#
#
body :greetings => "Hi"
#
Examples:
#
# Will make @greetings available in the template to be rendered.
def
body
(
object
=
nil
)
super
# Run deprecation hooks
if
object
.
is_a?
(
Hash
)
@assigns_set
=
true
object
.
each
{
|
k
,
v
|
instance_variable_set
(
:"@
#{
k
}
"
,
v
)
}
# render_message "special_message"
# render_message :template => "special_message"
# render_message :inline => "<%= 'Hi!' %>"
def
render_message
(
object
)
case
object
when
String
render_to_body
(
:template
=>
object
)
else
render_to_body
(
object
)
end
end
...
...
actionmailer/test/mail_service_test.rb
浏览文件 @
f00cbf78
...
...
@@ -120,11 +120,11 @@ def multipart_with_mime_version(recipient)
content_type
"multipart/alternative"
part
"text/plain"
do
|
p
|
p
.
body
=
"blah"
p
.
body
=
render_message
(
:text
=>
"blah"
)
end
part
"text/html"
do
|
p
|
p
.
body
=
"<b>blah</b>"
p
.
body
=
render_message
(
:inline
=>
"<%= content_tag(:b, 'blah') %>"
)
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录