rubyTrials

A way to keep track of breakthroughs I've made in Ruby and Ruby on Rails.

My Photo
Name:
Location: Cadillac, Michigan, United States

Monday, March 20, 2006

ruby on rails // current_page?

I recently ran into a situation where I needed to know what the current page was in order to apply the proper css class in a view in rails. [That's a long sentence ;)] Anyways it turns out to be cake. Snippet:


<ul>
<% unless current_page? :action => "index" %>
<li><%= link_to "Home", {:action => "index"} %></li>
<% else %>
<li class="tab_menu_active">Home</li>
<% end %>
</ul>


Also, in case anyone wondered, this is code from a divless/tableless layout. I do all of my sites this way now.