Skip to content

exAspArk/auto_breadcrumbs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
  1. Fill your locale file:
en:
  auto_breadcrumbs:
    root: 'Home'
    actions:
      new: 'New'
      show: 'Show'
      edit: 'Edit'
    controllers:
      users:
        index: 'Users'
        edit: 'Settings'
        sync: 'Synchronization'
      ...
  1. 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

About

🍞 Automatically add breadcrumbs to each page by using locales

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages