954,176 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Newbie question about embedding ruby in html

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

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


Thank you so much !

stilllearning
Posting Whiz
309 posts since Oct 2007
Reputation Points: 161
Solved Threads: 43
 

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.

blocblue
Posting Pro in Training
475 posts since Jan 2008
Reputation Points: 142
Solved Threads: 79
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You