ActionMailer 呈现更多然后需要
ActionMailer renders more then needed
class UserMailer
def notification_email(user, msg_body, msg_count)
@user = user
@msg_body = msg_body
mail(to: @user.email, subject: "New comments. #{msg_count}.")
end
notification_email.html.erb
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>You have new comments </h1>
<p>
<ul>
<%= @msg_body.each do |msg| %>
<li><a href="<%= msg %>"><%= msg %></a></li>
<% end %>
</ul>
</p>
</body>
</html>
对于消息正文,我传递给视图数组 msg_body。在 mailcatcher 中,我可以根据需要查看 href 列表。但我也看到列表后面的数组是纯文本。实在是看不懂从哪里来。
尝试将 <%= @msg_body.each do |msg| %>
更改为 <% @msg_body.each do |msg| %>
- 从每个块中删除相等项
class UserMailer
def notification_email(user, msg_body, msg_count)
@user = user
@msg_body = msg_body
mail(to: @user.email, subject: "New comments. #{msg_count}.")
end
notification_email.html.erb
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>You have new comments </h1>
<p>
<ul>
<%= @msg_body.each do |msg| %>
<li><a href="<%= msg %>"><%= msg %></a></li>
<% end %>
</ul>
</p>
</body>
</html>
对于消息正文,我传递给视图数组 msg_body。在 mailcatcher 中,我可以根据需要查看 href 列表。但我也看到列表后面的数组是纯文本。实在是看不懂从哪里来。
尝试将 <%= @msg_body.each do |msg| %>
更改为 <% @msg_body.each do |msg| %>
- 从每个块中删除相等项