views:

40

answers:

3

I have an admin with a nav. The nav toggles between different partials.

The nav has several li's, and when one of them is selected, it gets the .selected class that makes it highlighed.

Is there anyway to toggle this from the controller? Or any other place that's popular among Rubyists?

A: 

Use gem simple-navigation. It solves this and many other problems.

Link to GitHub

sharas
+1  A: 

I've not seen a standard solution for this, but the helper current_page? may be the answer.

Chubas
+2  A: 
%ul
  [email protected] do |link|
    %li= link_to_unless_current(link.title, link){link.title, link, :class => "selected"}

link_to_unless_current takes a block which is the block to render if it is current.

Jed Schneider