【发布时间】:2020-03-10 23:14:10
【问题描述】:
我正在做Ruby on Rails 教程https://www.learnenough.com/ruby-on-rails-6th-edition-tutorial/account_activation#sec-mailer_templates 并且我生成了一个User mailer 用于帐户激活。
代码如下:
app/views/user_mailer/account_activation.text.erb
Hi <%= @user.name %>,
Welcome to the Sample App! Click on the link below to activate your account:
<%= edit_account_activation_url(@user.activation_token, email: @user.email) %>
app/views/user_mailer/account_activation.html.erb
<h1>Sample App</h1>
<p>Hi <%= @user.name %>,</p>
<p>
Welcome to the Sample App! Click on the link below to activate your account:
</p>
<%= link_to "Activate", edit_account_activation_url(@user.activation_token,
email: @user.email) %>
我了解它们之间的区别(“HTML 是网页和电子邮件模板的编码方式,以便对文本进行格式化并添加图像。纯文本是常规文本,没有粗体、斜体、下划线等格式选项,或特殊布局选项”来源:https://www.cakemail.com/blog/html-vs-plain-text/),
但我不明白为什么有两个文件具有相同的嵌入式 Ruby 代码。我可以将它们混合在一个文件中吗?
【问题讨论】:
标签: html ruby-on-rails ruby