user2012677
user2012677

Reputation: 5755

image_url not working within action mailer (Ruby on rails)

I added the following in my production.rb environment file.

config.action_mailer.default_url_options = {host: "domain.com"}

In my view:

<%= tag("img", src: image_url("logo.png"))  %>

However, when I look at the path in my email, I see a image_path, not URL.

http:///assets/logo.png

What am I doing wrong?

Upvotes: 1

Views: 1409

Answers (3)

Neeraj Rana
Neeraj Rana

Reputation: 452

This is how it works in my application. Try this

<%= image_tag(attachments['logo.png'].url, style: 'margin: 5px') %>

Upvotes: 1

luckyruby
luckyruby

Reputation: 273

You need to specify config.action_mailer.asset_host = "domain.com" in production.rb. Then use image_tag in your mailer view.

Upvotes: 1

Brian
Brian

Reputation: 5501

Try asset_path instead of image_url in production email views.

Upvotes: 1

Related Questions