public
Description: Breadcrumbs for Rails with special sauce.
Homepage:
Clone URL: git://github.com/fesplugas/breadcrumbs.git
Francesc Esplugas (author)
Fri Apr 24 03:05:08 -0700 2009
name age message
file .gitignore Mon Apr 13 22:52:25 -0700 2009 Added git ignore. Signed-off-by: Francesc Espl... [midas]
file MIT-LICENSE Thu Apr 02 15:42:45 -0700 2009 Updated README [Francesc Esplugas]
file README.rdoc Fri Apr 24 03:05:08 -0700 2009 Fixed markup. [Francesc Esplugas]
file Rakefile Thu Apr 23 06:10:16 -0700 2009 Plugin is now called breadcrumbs. [fesplugas]
file init.rb Thu Apr 23 05:50:32 -0700 2009 Major rewrite of upstream code. * Support add_... [Chris Hapgood]
directory lib/ Thu Apr 23 05:55:10 -0700 2009 Small cleanup. [Francesc Esplugas]
README.rdoc

Simplified Breadcrumbs

A nice way to add breadcrumbs to your application. Antonio Cangiano posted a link in the Ruby on Rails weblog to a post which talked about adding breadcrumbs to your Rails application. I’ve been doing this with helpers, but as the post says this is "Easy and flexible". So I’ve created the plugin.

Changes

Changed breadcrumb method to accept 3 options: :wrap_with_tag, :class and :separator.

  • :wrap_with_tag - An HTML tag to wrap each breadcrumb entry with (ie. li, p, etc.).
  • :class - An HTML class to give to the tag specified in the +:wrap_with_tag+ option.
  • :separator - Acts the same as the old breadcrumb method worked.

Example

  ##
  # app/controllers/application.rb
  #
  class ApplicationController < ActionController::Base

    add_breadcrumb 'Home', :root_path

  end

  ##
  # app/controllers/things_controller.rb
  #
  class ThingsController < ApplicationController

    add_breadcrumb 'Things', :things_path
    add_breadcrumb 'Create a new thing', '', :only => [:new, :create]
    add_breadcrumb 'Edit a thing', '', :only => [:edit, :update]

    def show
      @thing = Thing.find(params[:id])
      add_breadcrumb @thing.name, thing_path(@thing)
    end

  end

  ##
  # app/views/layouts/application.html.erb
  #
  <%= breadcrumb %>
  <%= breadcrumb(:separator => '=>') %>
  <%= breadcrumb(:wrap_with_tag => 'li') %>

Acknowledgments

Copyright © 2008-2009 Francesc Esplugas, released under the MIT license