3
我需要保存有关将数据库中的每封电子邮件发送到我的客户端以进一步分析的信息。所以我试图在Observer中做到这一点,但我需要关于发票的信息。 所以我有梅勒:将其他信息传递给ActionMailer Observer
class ClientMailer < ActionMailer::Base
default :from => "[email protected]"
def remind(client, invoices)
@client = client
@company = @client.company
@invoices = invoices.to_a
@template = t('message.template')
@text = liquid_parse @template
@html = markdown_parse @text
mail(:to => @client.email, :subject => t('message.title')) do |format|
format.html
format.text
end
end
private
def markdown_parse(text)
markdown = Redcarpet::Markdown.new Redcarpet::Render::HTML,
:autolink => true, :space_after_headers => true
markdown.render text
end
def liquid_parse(text)
renderer = Liquid::Template.parse text
renderer.render 'company' => @company, 'invoice' => @invoice, 'client' => @client
end
end
而问题是:如何通过@invoices
到的ActionMailer观察员?