Rails ternary operator

I'm new to Rails, so forgive me if this is something simple, but it seems that what I wrote is correct. I use the ternary operator, in my opinion, to decide whether to add an active class or not:

<li class="<% is_current_page('') ? 'active' : '' %>">

And I debugged and know what is_current_page('')returns true.

+4
source share
3 answers

you skipped it =

<li class="<%= is_current_page('') ? 'active' : '' %>">
+15
source

Perhaps you wanted to do

<li class="<%= is_current_page('') ? 'active' : '' %>">
+2
source

here is what you need to do: <li class="<%= is_current_page('') ? 'active' : '' %>">

0
source

All Articles