rails way to make a tag class active in view?

Assuming that the "index.html" would actually be based on the 1, 2, etc.:

<ul>
<% for example in @examples %>
<li><%= link_to_unless_current example, example_path(example) do |text|
           content_tag(:span, text, :class => 'active')
         end %></li>
<% end %>
</ul>

When @examples = [1,2,3,4,5]
and example_path(3) => "/example/3"

Gives:
<ul>
<li><a href="/example/1">1</li>
<li><a href="/example/2">2</li>
<li><span class='active'>3</span></li>
<li><a href="/example/4">4</li>
<li><a href="/example/5">5</li>
</ul>

Is that what you're looking for? The link_to_if, link_to_unless, link_to_unless_current helpers take a block that is passed the text of the link when the condition isn't satisfied for making the link.

-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com