I tend to generate my own helper for this kind of thing:
#navigation_helper.rb
def nav_item(name, link, hilight = false)
content_tag :li, link_to(name, link), :class => ("selected" if hilight)
end
Then in your views just pass a relevant boolean to the helper:
<ul id="menu">
<%= nav_item "Foo admin", admin_path, (params[:controller] == "admin") %>
<%= nav_item "Bar page", pages_path(@page), (params[:controller] == "pages" && params[:action] == "show" && params[:id] == @page.id) %>
<%= nav_item "Baz example", example_path, any_old_helper? %>
</ul>
You'd need to think of a way of implementing this technique for your dynamically generated collection of pages, but where there's a will there's a way. :)