Rails 5 Action Mailer - 大虾PDF参数个数错误
Rails 5 Action Mailer - Prawn PDF wrong number of arguments
我在我的rails应用程序中设置了大虾生成:
format.pdf do
pdf = SalesByDayPdf.new(@daily_salesnp, @amount_total, @discount_total, @grand_total)
pdf.render_file "daily_sales.pdf"
send_data pdf.render, filename: 'daily_sales.pdf', type: 'application/pdf', disposition: 'inline'
end
这是我的 SalesByDayPdf
def initialize(daily_salesnp, grand_total, discount_total, amount_total)
super()
@daily_salesnp = daily_salesnp
@amount_total = amount_total
@discount_total = discount_total
@grand_total = grand_total
header
text_content
table_content
footer
end
这很好用。
现在我想从 action mailer 发送这个 pdf。我在 DailySalesMailer 中将其设置为:
def send_daily_sale(daily_salesnp, grand_total, discount_total, amount_total)
@daily_salesnp = daily_salesnp
@amount_total = amount_total
@discount_total = discount_total
@grand_total = grand_total
attachments["daily_sales.pdf"] = SalesByDayPdf.new(daily_salesnp, grand_total, discount_total, amount_total)
mail(:to => "email@gmail.com", :subject => 'Sales by Day Report')
end
所以基本上我在邮件程序中复制了 pdf 生成器并传递了在我的控制器中定义的相同参数。
但我得到:
wrong number of arguments (given 1, expected 4)
我做错了什么?
解决办法是修改附件为:
attachments["daily_sales.pdf"] = SalesByDayPdf.new(daily_salesnp, grand_total, discount_total, amount_total).render
我在我的rails应用程序中设置了大虾生成:
format.pdf do
pdf = SalesByDayPdf.new(@daily_salesnp, @amount_total, @discount_total, @grand_total)
pdf.render_file "daily_sales.pdf"
send_data pdf.render, filename: 'daily_sales.pdf', type: 'application/pdf', disposition: 'inline'
end
这是我的 SalesByDayPdf
def initialize(daily_salesnp, grand_total, discount_total, amount_total)
super()
@daily_salesnp = daily_salesnp
@amount_total = amount_total
@discount_total = discount_total
@grand_total = grand_total
header
text_content
table_content
footer
end
这很好用。
现在我想从 action mailer 发送这个 pdf。我在 DailySalesMailer 中将其设置为:
def send_daily_sale(daily_salesnp, grand_total, discount_total, amount_total)
@daily_salesnp = daily_salesnp
@amount_total = amount_total
@discount_total = discount_total
@grand_total = grand_total
attachments["daily_sales.pdf"] = SalesByDayPdf.new(daily_salesnp, grand_total, discount_total, amount_total)
mail(:to => "email@gmail.com", :subject => 'Sales by Day Report')
end
所以基本上我在邮件程序中复制了 pdf 生成器并传递了在我的控制器中定义的相同参数。
但我得到:
wrong number of arguments (given 1, expected 4)
我做错了什么?
解决办法是修改附件为:
attachments["daily_sales.pdf"] = SalesByDayPdf.new(daily_salesnp, grand_total, discount_total, amount_total).render