I find manually accessing the router to be quite ugly below. Is there
a more direct way to access it?

module ApplicationHelper

  def menu_item text, url = nil
    routes = ActionController::Routing::Routes

    url = if url
            if url.is_a? String
              url
            else
              routes.generate url
            end
          else
            routes.generate :controller => text
          end

    unless text.is_a? String
      text = t text
    end

    active = request.request_uri == url

    "<li #{'class="active"' if active}>#{ link_to text, url }</li>"
  end

end

Thomas

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to