I am really new to this, so please excuse me if this is a dumb question. I am saving some data using ruby on rails and one of those fields is a background for the divs I am rendering back on load. I created the partial layouts successfully but I have no clue how to embed the background into the div using the ruby variable.

So this is what I would do in jQuery
<div id="bubble" class="bubble" style="background:' + icon + '"></div>

My ruby field is <% event.icon %> ... how do I add it to this div ?


Thank you so much !

Hi,

Assuming your html file has an .rhtml, .erb or basically an extension that will ensure it is run through the ruby parser, then you can do this:

<div id="bubble" class="bubble" style="background: <%= event.icon %>">

</div>

R.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.