I want to define the width of a status bar dynamically.
First I define the variable:
<% target = (clicks/total_clicks)*100 %>
Then I try to embed the ruby code into a css width tag:
<div class="bar" style="width: <%= target %>%">
However, the html output looks like this
<div class="progress progress-striped">
<div class="bar" style="width: 0%"></div>
</div>
I tried to convert the target var as a string:
<% target = ((clicks/total_clicks)*100).to_s %>
I obviously also tried to assign a not-dynamic value as well:
<% target = 40.to_s %>
But with no success.
How can I embed a ruby var into a CSS style tag? Thanks for any help.