def menu_entry name url content_tag li link_to_unless_curre nt_path na

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
def menu_entry(name, url)
content_tag(:li, link_to_unless_current_path(name, url), current_path?(url) ? { :class => "active" } : {} )
end
def current_path?(options)
url_string = CGI.unescapeHTML(url_for(options))
request = @controller.request
request_uri = request.request_uri.split('?').first
if url_string =~ /^\w+:\/\//
"#{request.protocol}#{request.host_with_port}#{request_uri}".start_with? url_string
else
request_uri.start_with? url_string
end
end
def link_to_unless_current_path(name, options = {}, html_options = {}, &block)
link_to_unless current_path?(options), name, options, html_options, &block
end