=context_sensitive_link_to ==Installation: script/plugin install http://svn.redshiftmedia.com/svn/plugins/context_sensitive_link_to ==Usage: ===In your controller Populate a instance variable array called @ancestor_urls. @ancestor_urls should be filled with the url of the page which is about to be displayed to the user, plus all the pages that should be considered 'parents' of that page. class WorksController < ApplicationController def index # application code here @ancestor_urls=[{:controller=>:works,:action=>:index}] end def overview # application code here @ancestor_urls=[{:controller=>:works,:action=>:overview}] end # When viewing favourites.rhtml, links to :overview and :favourites should be highlighted def favourites # application code here @ancestor_urls=[{:controller=>:works,:action=>:overview}, {:controller=>:works,:action=>:favourites}] end end ===In your views context_sensitive_link_to(name, options = {}, html_options = nil, *parameters_for_method_reference) Works exactly like link_to except that if the url is found in the contents of @ancestor_urls, the link will receive an extra class of "ancestor_of_current_page", which means it can be highlighted to show the users position within the site.
  • <%= context_sensitive_link_to("Works",{:controller=>:works})%>
  • return_highlight_class(url={}) Sometimes you don't want to create a link, but do want to style an element differently depending on what the current page is. This method returns either "" or "ancestor_of_current_page" depending on whether or not the url was found in the contents of the instance variable @ancestor_urls. Example:

    Works

    == Resources Subversion * http://svn.redshiftmedia.com/svn/plugins/context_sensitive_link_to Author * Tomasz Kaye. info [at] redshiftmedia [dot] com