Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Automatically add breadcrumbs to each page by using locales
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
config/locales
lib
spec
.rspec
.travis.yml
Gemfile
LICENSE.txt
README.md
Rakefile
auto_breadcrumbs.gemspec

README.md

Auto Breadcrumbs Build Status

Automatically add breadcrumbs to each page by using locales and gem breadcrumbs_on_rails.

Installation

Add this line to your application's Gemfile:

gem 'auto_breadcrumbs'

And then execute:

$ bundle

To generate locale file run:

$ rails g auto_breadcrumbs:install

Usage

1) Include auto_breadcrumbs in your controller:

class ApplicationController < ActionController::Base
  include AutoBreadcrumbs
  ...
end

2) Fill your locale file:

en:
  auto_breadcrumbs:
    root: 'Home'
    actions:
      new: 'New'
      show: 'Show'
      edit: 'Edit'
    controllers:
      users:
        index: 'Users'
        edit: 'Settings'
        sync: 'Synchronization'
      ...

3) Use helper method to show breadcrumbs in your view file:

<body>
  <%= render_breadcrumbs %>
</body>

For example, if you go to /users/1/edit it will show breadcrums like Home / Users / Settings.

In case when translations are absent it will try to build breadcrumbs automatically depending on resource and action names. For example, if you visit /countries/new it will show breadcrums Home / Countries / New.

You can also use helper methods resource_translation and action_translation like this:

<!DOCTYPE html>
<html>
  <head>
    <title><%= [resource_translation, action_translation].compact.join(' | ') %></title>
  </head>
</html>

Customization

For more information about customization of breadcrumbs visit breadcrumbs_on_rails.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.