HAML: %li{:class => 'current' if page == 2} does not work?

Hi all

I'm iterating over navigation page links using HAML. I want to assign the current page's link the CSS class .current trying to use:

%li{:class => 'current' if params[:page] == i}

Sadly this doesn't work. How can I achieve the wanted result?

Thanks for help, Josh

params are always returned as strings. Use params[:page].to_i == i or params[:page] == i.to_s. See if that works.

Steve Ross wrote:

I use this line in HAML, and that works fine.

%li{:class => ("active" if item[:item] == active_menu_item)}

so maybe it's the ( ) that do the trick?

Peter wrote:

I use this line in HAML, and that works fine.

%li{:class => ("active" if item[:item] == active_menu_item)}

so maybe it's the ( ) that do the trick?

On Feb 18, 10:56 am, Joshua Muheim <rails-mailing-l...@andreas-s.net>

Yes, this seemed to be the problem. Thanks.