我的郵件看起來是這樣的:如何在郵件程序中設置全局變量,取決於參數?
class RenovationOrderMailer < ApplicationMailer
default from: "[email protected]"
def customer_confirmation(renovation_order)
@renovation_order = renovation_order
mail(to: "[email protected]", subject: 'We confirm!')
end
def order_summary(renovation_order)
@renovation_order = renovation_order
mail(to: "[email protected]", subject: 'You have new order!')
end
def custom_email(renovation_order)
@renovation_order = renovation_order
mail(to: "[email protected]", subject: 'Info about order')
end
def custom_email_confirmation(renovation_order)
@renovation_order = renovation_order
mail(to: "[email protected]", subject: 'You sended info')
end
end
正如你可以在每一個方法見我宣佈@renovation_order
變量,我需要在方法視圖。有沒有解決方法來聲明這個變量一次,並有權訪問郵件中的每一個方法?
我知道這裏有toppic:https://stackoverflow.com/a/18709805/2502605,但沒有關於創建共享視圖變量,傳遞數據做郵件發送器before_action和語法。
可能的重複[如何在UserMailer中添加一個before \ _filter,它檢查是否可以向用戶發送郵件?](http://stackoverflow.com/questions/8594626/how-to-add-a-before -filter-in-usermailer-which-checks-if-it-is-ok-to-mail-a-user) – engineersmnky