I have my code as below
<% reported_type = 4 %>
<%=
if reported_type == 1
link_to "1 is true", true_path
else
link_to "1 is false", false_path
end
if reported_type == 2
link_to "2 is true", true_path
else
link_to "2 is false", false_path
end
if reported_type == 3
link_to "3 is true", true_path
else
link_to "3 is false", false_path
end
%>
Expected Output: 1 is false2 is false3 is false
But actual output is 3 is false
When I comment out the third if ... else
block, I get 2 is false
.
If it is because of <%= ... %>
, then no if statement must be rendered, right?
As I am new to Rails, I can't figure out why only the last if statement is rendered. If I mix <%= ... %>
and <% .. %>
, my code will not look nice (As I require every block to be executed). Please help me out.