module ActionView module Helpers module UrlHelper def return_highlight_name "ancestor_of_current_page" end # Assumes the presence of @ancestor_urls array. def in_ancestors_array? url={} if @ancestor_urls and !url.empty? link_url=url_for url @ancestor_urls.each do |a| ancestor_url=url_for a if link_url==ancestor_url return true break end end return false else return false end end def context_sensitive_link_to(name, options = {}, html_options = nil, *parameters_for_method_reference) if in_ancestors_array? options if !html_options.nil? and !html_options[:class].nil? html_options[:class]=html_options[:class]+" "+return_highlight_name elsif !html_options.nil? and html_options[:class].nil? html_options.merge({:class=>return_highlight_name}) else html_options={:class=>return_highlight_name} end end return(link_to(name, options, html_options, *parameters_for_method_reference)) end def return_highlight_class url={} if !url.empty? and in_ancestors_array?(url) return_highlight_name else "" end end end end end