我有一個郵件看起來像(@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