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觀察員?