has_breadcrumbs is a simple plugin that adds a `breadcrumb` object into controllers and views.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
lib
spec
MIT-LICENSE
README.textile
init.rb

README.textile

has_breadcrumbs

has_breadcrumbs is a simple plugin that adds a breadcrumb object into controllers and views.

Instalation

1) Install the plugin with `script/plugin install git://github.com/danielvlopes/has_breadcrumbs.git`

Usage

On your controller:

class ApplicationController < ActionController::Base
  before_filter :add_initial_breadcrumbs

  private
    def add_initial_breadcrumbs
      breadcrumb.add 'Home', root_path
    end
end

class ThingsController < ApplicationController
  def index
    # you can also use << instead of .add
    breadcrumb.add 'Things', things_path
  end
end

You don’t need to provide an URL; in that case, a span will be generated
instead of a link:

breadcrumb.add 'Some page'

You can set additional HTML attributes if you need to:

breadcrumb.add 'Home', root_path, :id => 'home', :title => 'Go to the home page'

On your view:

You are here: <%= breadcrumb.display %>

You can set your own separator:

You are here: <%= breadcrumb.display %>

The output in your html will be something like below:

  <ul id="breadcrumbs">
    <li class="item-0"><a href="#">Home</a></li>
    <li class="item-1"><a href="#">Main section</a></li>
    <li class="item-2"><a href="#">Sub section</a></li>
    <li class="item-3 last">The page you are on right now</li>
  </ul>

For a good css example take a look in examples folder.

This work is based on http://github.com/fnando/has_breadcrumbs/tree/master by Nando Vieira.

Adaptation made by Daniel Lopes, under the MIT license.