Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing host in link_to methods #2

Open
palodelincak opened this issue Apr 10, 2013 · 4 comments
Open

Missing host in link_to methods #2

palodelincak opened this issue Apr 10, 2013 · 4 comments

Comments

@palodelincak
Copy link

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.

@jcoleman
Copy link
Owner

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

Also the version of Rails would be helpful.

@palodelincak
Copy link
Author

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.

@jcoleman
Copy link
Owner

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

@palodelincak
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants