Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
has_breadcrumbs is a simple plugin that adds a `breadcrumb` object into controllers and views.
branch: master

This branch is 20 commits ahead of danielvlopes:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
lib
spec
.gitignore
MIT-LICENSE
README.textile
Rakefile
VERSION
has_breadcrumbs.gemspec
init.rb

README.textile

has_breadcrumbs

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

Installation

Rails 2.3:

config.gem 'has_breadcrumbs'

Bundler:

gem 'has_breadcumbs'

Usage

On your controller:

class ApplicationController < ActionController::Base
  before_filter :add_home_breadcrumb

  protected

  def add_home_breadcrumb
    breadcrumb.add 'Home', root_path
  end
end

class PostsController < ApplicationController
  def index
    breadcrumb.add 'Posts', posts_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 %>

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 by Nando Vieira.

Adaptation made by Daniel Lopes and Gabriel Sobrinho, under the MIT license.

Something went wrong with that request. Please try again.