1

I am trying to put an image on a mailer view using <%= image_tag("logo.png", :alt => "logo") %>. This works using an online link so I think the problem is figuring out the path. When the email is sent, the image does not appear and only the text 'logo' is showing.

I have the logo image at project_name > app > assets > images > logo.png.

I also have a public directory structured project_name > public > assets > image_and_js_files

What is the proper path I should use?

user1584575
  • 731
  • 3
  • 10
  • 20

2 Answers2

1

you can use

<%= image_tag("/assets/logo.png", :alt => "logo")

allenwei
  • 4,047
  • 5
  • 23
  • 26
  • I've tried this before. It only shows me the text 'logo'. I've also tried all the directories above it with the same result. – user1584575 Jul 21 '14 at 03:42
  • can you give me more information 1) what's the link generated 2) the file path you suppose to use – allenwei Jul 21 '14 at 03:49
  • There is no link generated. Just a text 'logo' where I want the logo image to appear. I am trying to figure out the file path. I know the image is in ``project_name > app > assets > images > logo.png`` and in ``project_name > public > assets > image_in_some_format``. – user1584575 Jul 21 '14 at 03:55
  • how about `image_path`? – allenwei Jul 21 '14 at 03:58
  • I tried using ``<%= image_tag("#{image_path 'logo.png'}", :alt => "logo") %>``. It still only shows text 'logo'. – user1584575 Jul 21 '14 at 04:02
  • it only show text logo, is because link is empty, or the image can not find. what's the html generated – allenwei Jul 21 '14 at 04:22
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/57643/discussion-between-allenwei-and-user1584575). – allenwei Jul 21 '14 at 04:32
0

You have to specify the absolute link in your email in order to get it works. image_tag will only generate relative path, ex: /assets/logo.png.

Ex: https://stackoverflow.com/a/24561439/461640

Community
  • 1
  • 1
The Lazy Log
  • 3,564
  • 2
  • 20
  • 27
  • Can you elaborate further? For now, I am accessing my files in my ``assets`` folder. I do not have a CDN delivering my files. Does asset hosting allow use of relative paths? – user1584575 Jul 21 '14 at 07:56