2015-10-06 28 views
0

我的邮件看起来是这样的:如何在邮件程序中设置全局变量,取决于参数?

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和语法。

+0

可能的重复[如何在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

回答