title: Ruby on Rails Syntax for Background Image in HTML.ERB file
body: <p>I have many articles so I can't put a static URL to background-image under <code>syle="background-image</code>.</p>
  
  <p>I tried this in my _article.html.erb file:-</p>
  
  <pre><code>&lt;div class="hero_image" style="background-image: url("&lt;%= article.image_url %&gt;")"&gt;
  </code></pre>
  
  <p>but it renders out this:</p>
  
  <pre><code>&lt;div class="hero_image" style="background-image: url(" uploads="" lines="" article="" hero_image="" 1="" budapest-cropped.jpg")"=""&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>so, nevermind, I try this instead under my article.scss.erb file:-</p>
  
  <pre><code>  .hero_image {
      background-image: url(&lt;%= asset_path 'article.image_url' %&gt;);
  </code></pre>
  
  <p>but it renders out this:</p>
  
  <pre><code>background-image: url(/article.image_url);
  </code></pre>
  
  <p>Totally not what I'm looking for, I need it to render out </p>
  
  <p><code>&lt;div class="hero_image" style="background-image: url("/uploads/lines/article/hero_image/1/Budapest_Cropped.jpg"&gt;
          &lt;/div&gt;</code> under HTML OR <code>background-image: url(/uploads/lines/article/hero_image/1/Budapest_Cropped.jpg);</code> under CSS</p>
  
  <p>Ironically, it knew exactly what to do when my code is <code>&lt;img src="&lt;%= article.image_url %&gt;" alt="&lt;%= article.title %&gt;" /&gt;</code>, but too bad, i don't want a img src tag, i need a background image tag.</p>
  
  <p>Anyone knows what is wrong with my syntax?</p>
  
  <p>Thank you in advance!</p>