質問

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?

役に立ちましたか?

解決 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" %>">

他のヒント

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top