mail_alternatives_with_attachments
mail_alternatives_with_attachments copied to clipboard
Missing host in link_to methods
Hello. I'm using your gem to send PDF attachments - everything works like a charm, but when I changed classic mail
to prepare_message
- link_to methods stopped appending host to all links in mailer view.
Can you post the contents of your method in your mailer class?
Also the version of Rails would be helpful.
Rails 3.2.11
I'm using mail_alternatives_with_attachments in OrderMailer (there it works, but link_to isn't appending host).
My mail method:
def shipped_with_attachments(order, items, entity)
@order = order
@entity = entity
@items = items
@document = @entity
message = prepare_message(to: "\"#{@order.address.name_surname}\" <#{@order.address.email}>", subject: t('mailers.order_mailer.shipped.subject', number: @order.string_number), content_type: "multipart/mixed")
message.alternative_content_types_with_attachment(
html: render_to_string(template: "order_mailer/shipped.html.haml")
)
attachments["#{@document.string_number}.pdf"] = WickedPdf.new.pdf_from_string(
render_to_string(
pdf: "#{@document.string_number}",
template: "documents/show.pdf.haml",
layout: "layouts/pdf.html.haml")
)
message
end
I've got UserMailer also - this mailer stopped working after I added mail_alternatives_with_attachments to Gemfile. It was raising Missing host to link to! Please provide :host parameter or set default_url_options[:host]
. But it's working without your gem.
That code isn't using the gem. Could you post the code using the gem?
Ooops. Sorry about that. I've updated my previous comment with code using the gem.