我想在我的 Rails 邮件程序的主题行中包含以下代码,但无法使其工作。正确的语法是什么?谢谢!
<%= @occasions.map{|o|o.pname+"'s "+o.name}.to_sentence %>
邮寄者:
def upcoming_deals_mail(user)
@user = user
@occasions = user.upcoming_occasions_with_deals
@deals = user.upcoming_deals
@subject = "An friendly Reminder"
mail(:to => "#{ user.email } <#{ user.email }>", :subject => @subject)
end
最佳答案
添加双引号("")而不是单引号(' ')对我来说是这样的
失败:
mail(to: '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b4c0d1c7c0f4d1d9d5ddd89ad7dbd9" rel="noreferrer noopener nofollow">[email protected]</a>', subject: 'Application for: #{@applicant.full_name}')
成功:
mail(to: '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bfcbdacccbffdad2ded6d391dcd0d2" rel="noreferrer noopener nofollow">[email protected]</a>', subject: "Application for: #{@applicant.full_name}")
关于ruby-on-rails - 在 Rails Mailer 主题行中包含 ERB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11378912/