image_tag

I have an table with a background image but I do not know how to load
the image.

In general I use a code line like
"<td height="50" background="../images/5.png">"
but this do not work, because the directory changes, for example if I
open a sub page of my controller, the picture is gone. Please just tell
me how to use the image_tag with the background tag in html.

Regrades Snoop1990

Image tag generates <img src=> i'm pretty sure.

Why are you doing ../? Just make it /

I have an table with a background image but I do not know how to load
the image.

In general I use a code line like
"<td height="50" background="../images/5.png">"
but this do not work, because the directory changes, for example if I
open a sub page of my controller, the picture is gone. Please just tell
me how to use the image_tag with the background tag in html.

image_path("edit.png") # => /images/edit.png
image_path("icons/edit.png") # => /images/icons/edit.png
image_path("/icons/edit.png") # => /icons/edit.png

Philip Hallstrom wrote:

image_path("edit.png") # => /images/edit.png
image_path("icons/edit.png") # => /images/icons/edit.png
image_path("/icons/edit.png") # => /icons/edit.png

I tried <td height="150" background=" <=%image_path("1.png")%> ">
but it does not work ! How to tell ruby on rails it should render the
command when using it inside a html command ?

<td height="150" background=" <=%image_path("1.png")%> ">

Well, it's supposed to be <%=, but that was probably a typo.

From your example, it looks like you've got double quotes (") nested
inside other double quotes.

Have you tried:

<td height="150" background=" <=%image_path('1.png')%> ">

-Steve

Steve wrote:

From your example, it looks like you've got double quotes (") nested
inside other double quotes.

Have you tried:

<td height="150" background=" <=%image_path('1.png')%> ">

-Steve

Thank you very much, it is all working now !
Regrades Snoop1990