Search code examples
ruby-on-railsrubyactionview

Rails ERB view syntax issue


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?


Solution

  • 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" %>">