unable to successfully interpolate strings in Ruby -


i'm noob rails trying create partial passed collection.

there variable counter defined inside partial implicit collection passed in called _counter referencing update row names benefit of css selectors. code looks this:

<div class=<%= "column1--row" + product_counter.to_s + " column1--row" %> > <img src=<%= "http://fillmurray.com/" + (size + product_counter).to_s + "/" + (size + product_counter).to_s %> alt="product1" class="product-image"> <div class="description">     <span class="title"><%= product.title %></span><br>     <span class="details"><%= product.description %></span>     <span class="rank">       <i class="fa fa-caret-up" aria-hidden="true">936</i>     </span>     <span class="comments"><i class="fa fa-comment" aria-hidden="true">45</i>     </span> </div> 

but html top div ends looking this:

<div class="column1--row0" column1--row=""> <img src="http://fillmurray.com/155/155" alt="product1" class="product-image"> <div class="description">     .... 

so div class ends wrong selector. i've tried bunch of different interpolations , result same:

this :

<div class=<%"column1--row#{product_counter.to_s} column1--row" 

and few others including concat method of string class. i'm guessing there's obvious i'm missing i'm not getting problems concatenating strings in img src tag.

thanks in advance.

try this:

<div class=" <%= 'column1--row' + product_counter.to_s + ' column1--row' %> " >   <img src= " <%= 'http://fillmurray.com/' + (size + product_counter).to_s + '/' + (size + product_counter).to_s %> " alt="product1" class="product-image">   <div class="description">     <span class="title"><%= product.title %></span><br>     <span class="details"><%= product.description %></span>     <span class="rank">      <i class="fa fa-caret-up" aria-hidden="true">936</i>     </span>     <span class="comments"><i class="fa fa-comment" aria-hidden="true">45</i>     </span> </div> 

Comments

Popular posts from this blog

mongodb - How to keep track of users making Stripe Payments -

javascript - Fire on return from form "Submit" -

javascript - Thinglink image not visible until browser resize -