mail_alternatives_with_attachments icon indicating copy to clipboard operation
mail_alternatives_with_attachments copied to clipboard

Missing host in link_to methods

Open palodelincak opened this issue 11 years ago • 4 comments

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.

palodelincak avatar Apr 10 '13 05:04 palodelincak

Can you post the contents of your method in your mailer class?

Also the version of Rails would be helpful.

jcoleman avatar Apr 10 '13 12:04 jcoleman

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.

palodelincak avatar Apr 10 '13 12:04 palodelincak

That code isn't using the gem. Could you post the code using the gem?

jcoleman avatar Apr 10 '13 13:04 jcoleman

Ooops. Sorry about that. I've updated my previous comment with code using the gem.

palodelincak avatar Apr 10 '13 14:04 palodelincak