html - Add extra class on basis of if ... else statement -


in view, i'm trying add additional class specification "active" on basis of page user on. have:

<li <%= if current_page?(root_path) class="hvr-bottom active" : class="hvr-bottom" %>><a href=<%= root_path %>>home</a></li> 

this generates error:

syntax error, unexpected keyword_class, expecting keyword_then or ';' or '\n' ... 

how should adjust code add additional class if specific page visited?

your current ternary statement seems missing ?. try following:

<li class=<%= current_page?(root_path) ? "hvr-bottom active" : "hvr-bottom" %>> ... </li> 

hope helps!


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -