943,202 Members | Top Members by Rank

Ad:
  • Ruby Discussion Thread
  • Unsolved
  • Views: 128
  • Ruby RSS
Jul 27th, 2010
0

Newbie question about embedding ruby in html

Expand Post »
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 !
Similar Threads
Reputation Points: 161
Solved Threads: 43
Posting Whiz
stilllearning is offline Offline
309 posts
since Oct 2007
Aug 10th, 2010
0
Re: Newbie question about embedding ruby in html
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:

ruby Syntax (Toggle Plain Text)
  1. <div id="bubble" class="bubble" style="background: <%= event.icon %>">
  2.  
  3. </div>

R.
Reputation Points: 101
Solved Threads: 74
Posting Pro in Training
blocblue is offline Offline
417 posts
since Jan 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Ruby Forum Timeline: Obeserve_field
Next Thread in Ruby Forum Timeline: where can i learn?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC