Skip to content

Instantly share code, notes, and snippets.

@jesusangelm
Created March 2, 2015 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesusangelm/a4e1e5a8aa3c19f2cf47 to your computer and use it in GitHub Desktop.
Save jesusangelm/a4e1e5a8aa3c19f2cf47 to your computer and use it in GitHub Desktop.
breadcrumb adaptado para TwitterBootstrap. le falta optimizacion.
def breadcrumbs(include_home = true)
levels = request.path.split('?')[0].split('/')
levels.delete_at(0)
links = content_tag("li") { content_tag('a', "Inicio", :href => root_path ) if include_home }
nocrumb = []
levels.each_with_index do |level, index|
level = level.gsub(/^[0-9]+\-/,"") #if levels[index-1] == "photos"
level = level.gsub("-", " ")
if index+1 == levels.length
elsif !nocrumb.include?(level)
links += content_tag("li") { content_tag('a', level.upcase, :href => '/'+levels[0..index].join('/')) }
end
end
content_tag("ol", links, :class => "breadcrumb")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment