ediblecode
ediblecode

Reputation: 11971

Ternary operator within Rails view

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.

Upvotes: 8

Views: 12925

Answers (3)

amit karsale
amit karsale

Reputation: 755

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

Upvotes: 0

bbozo
bbozo

Reputation: 7311

You probably wanted to do

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

Upvotes: 2

Amit Thawait
Amit Thawait

Reputation: 5292

You missed =

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

Upvotes: 19

Related Questions