Skip to content

Instantly share code, notes, and snippets.

@kent
Created May 20, 2009 03:17
Show Gist options
  • Save kent/114588 to your computer and use it in GitHub Desktop.
Save kent/114588 to your computer and use it in GitHub Desktop.
Rails Tabbed Navigation Helper
def layout_link_to(link_text, path, opts = {})
curl = url_for(:controller => request.path_parameters['controller'],
:action => request.path_parameters['action'])
html = ''
options = curl.include?(path) ? {:class => 'current'} : {}
if opts[:class] && options[:class]
options[:class] = "current #{opts[:class]}"
else
options.merge!(opts)
end
html << content_tag("li", link_to(link_text, path, options))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment