我有一个邮件看起来像(@user
和@foo
传递到含方法):我有一些放测试它串插不打印变量的值,在打印精确的字符串
mail(to: @user.email, subject: 'Foo is expired',
body: 'Your Foo reservation for #{@foo.bar.name} in position #{@foo.position}
has expired. Please recreate the reservation if necessary')
,把mail.body看起来像:
'Your Foo reservation for #{@foo.bar.name} in position #{@foo.position}
has expired. Please recreate the reservation if necessary'
我只是误认为我如何做插值?它与ActionMailer有什么关系,或者将文本输出到控制台?
谢谢。在ruby
使用'%Q考虑一个字符串,不引用,像这样的字符串插值:#{ruby_variable}!'如果你想使用引号但不能转义它们(引用:http://en.wikibooks.org/wiki/Ruby_Programming/Alternate_quotes) – MrYoshiji