Pregunta

I apparently can't get the syntax proper here:

<table width="100%" border="0" cellspacing="0" cellpadding="20" background="<%= #{Rails.root}/app/assets/images/image.png %>">

What's the appropriate way to do this?

¿Fue útil?

Solución 2

UPDATE:

Answer below shows correct syntax, but to display image path it is better to use @TomFeaks answer.

try this:

<table width="100%" border="0" cellspacing="0" cellpadding="20" background="<%= "#{Rails.root}/app/assets/images/image.png" %>">

Otros consejos

Rails provides asset helpers to get the path of image files, and that works with the Asset Pipeline and automatically works when you change the asset_host to use a CDN.

<table width="100%" border="0" cellspacing="0" cellpadding="20" background="<%= image_path('image.png') %>">

Here's the documentation on Asset Helpers

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top