Answer the question
In order to leave comments, you need to log in
Why is the code section ignored in the erb template?
The code:
<td><% if @statistics[service].has_key?(:errorsrate)
errorsrate = @statistics[service][:errorsrate].to_i
else
errorsrate = "-" %><%=
if errorsrate.is_a?(String)
if errorsrate > 5
'class="red"'
else
'class="green"'
end
end %>
<%end%> >
<%= errorsrate %> </td>
<td class="green">
8</td>
<td
>
8 </td>
Answer the question
In order to leave comments, you need to log in
Okay markup. But where is the logic?
By your code to get
<td class="green">
8</td>
@statistics[service]
did NOT have the errorsrate key Firstly, the use of logic in view templates falls under "wrong".
Secondly, the formatting is wildly simple, but this should not affect the work.
Thirdly, and most likely, the fact is that your second one if
is in the interpretive erb tag: <%= %>
A should be<% %>
Exactly. Victor, thank you so much for "blurring" my eyes. A very obvious mistake, really.
<td
<% if @statistics[ntag].has_key?(:errorsrate)
errorsrate = @statistics[ntag][:errorsrate].to_i
else
errorsrate = "-"
end%>
<%=
if !errorsrate.is_a?(String)
if errorsrate > 5
'class="red"'
else
'class="green"'
end
end %>>
<%= errorsrate %> </td>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question