问题描述:

I'm new to Rails, so forgive me if it's something simple, but it does seem as if though what I've written is correct. I'm using a ternary operator in my view to decide whether to add a class of active or not:

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

And I've debugged and know for sure that is_current_page('') is returning true.

网友答案:

You missed =

<li class="<%= is_current_page('') ? 'active' : '' %>">
网友答案:

You probably wanted to do

<li class="<%= is_current_page('') ? 'active' : '' %>">
网友答案:

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

相关阅读:
Top