{"id":13484278,"url":"https://github.com/weppos/breadcrumbs_on_rails","last_synced_at":"2025-05-14T10:11:29.726Z","repository":{"id":45676015,"uuid":"193842","full_name":"weppos/breadcrumbs_on_rails","owner":"weppos","description":"A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.","archived":false,"fork":false,"pushed_at":"2024-08-03T17:12:53.000Z","size":156,"stargazers_count":944,"open_issues_count":3,"forks_count":188,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-10-29T15:49:07.040Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://simonecarletti.com/code/breadcrumbs-on-rails","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weppos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":"rubygems/breadcrumbs_on_rails","community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2009-05-06T10:45:42.000Z","updated_at":"2024-10-28T13:39:10.000Z","dependencies_parsed_at":"2024-11-19T04:15:44.800Z","dependency_job_id":"85881a6f-e203-4623-a923-b1a142908b47","html_url":"https://github.com/weppos/breadcrumbs_on_rails","commit_stats":{"total_commits":158,"total_committers":16,"mean_commits":9.875,"dds":0.189873417721519,"last_synced_commit":"4e74436c0f3f5cdc16d05de92b67d97a45ba545a"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weppos%2Fbreadcrumbs_on_rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weppos%2Fbreadcrumbs_on_rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weppos%2Fbreadcrumbs_on_rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weppos%2Fbreadcrumbs_on_rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weppos","download_url":"https://codeload.github.com/weppos/breadcrumbs_on_rails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247968368,"owners_count":21025823,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:01:21.802Z","updated_at":"2025-04-09T03:09:44.052Z","avatar_url":"https://github.com/weppos.png","language":"Ruby","funding_links":["https://tidelift.com/funding/github/rubygems/breadcrumbs_on_rails","https://tidelift.com/badges/package/rubygems/breadcrumbs_on_rails","https://tidelift.com/subscription/pkg/rubygems-breadcrumbs.on.rails?utm_source=rubygems-breadcrumbs-on-rails\u0026utm_medium=referral\u0026utm_campaign=enterprise","https://tidelift.com/subscription/pkg/rubygems-breadcrumbs.on.rails?utm_source=rubygems-breadcrumbs-on-rails\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo"],"categories":["Ruby","Breadcrumbs","Gems","Navigation"],"sub_categories":["Articles"],"readme":"# Breadcrumbs On Rails\n\n\u003ctt\u003eBreadcrumbsOnRails\u003c/tt\u003e is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project. It provides helpers for creating navigation elements with a flexible interface.\n\n[![Build Status](https://github.com/weppos/breadcrumbs_on_rails/actions/workflows/tests.yml/badge.svg)](https://github.com/weppos/breadcrumbs_on_rails/actions/workflows/tests.yml)\n[![Tidelift dependencies](https://tidelift.com/badges/package/rubygems/breadcrumbs_on_rails)](https://tidelift.com/subscription/pkg/rubygems-breadcrumbs.on.rails?utm_source=rubygems-breadcrumbs-on-rails\u0026utm_medium=referral\u0026utm_campaign=enterprise)\n\n\n## Links\n\n- [Homepage](https://simonecarletti.com/code/breadcrumbs-on-rails)\n- [Repository](https://github.com/weppos/breadcrumbs_on_rails)\n- [API Documentation](https://rubydoc.info/gems/breadcrumbs_on_rails)\n\n\n## Requirements\n\n- Ruby \u003e= 2.4\n- Rails \u003e= 5\n\nFor older versions use a previous release.\n\n\n## Installation\n\nAdd this line to your application's `Gemfile`:\n\n```\ngem \"breadcrumbs_on_rails\"\n```\n\nAnd then execute `bundle` to install the dependencies:\n\n```\nbundle\n```\n\nUse [Bundler](http://bundler.io/) and the `:git` option if you want to grab the latest version from the Git repository.\n\n\n## Usage\n\nCreating a breadcrumb navigation menu in your Rails app using \u003ctt\u003eBreadcrumbsOnRails\u003c/tt\u003e is really straightforward.\n\nIn your controller, call `add_breadcrumb` to push a new element on the breadcrumb stack. `add_breadcrumb` requires two arguments: the name of the breadcrumb and the target path.\n\n```ruby\nclass MyController\n\n  add_breadcrumb \"home\", :root_path\n  add_breadcrumb \"my\", :my_path\n\n  def index\n    # ...\n\n    add_breadcrumb \"index\", index_path\n  end\n\nend\n```\n\nSee the section \"Breadcrumb Element\" for more details about name and target class types.\n\nThe third, optional argument is a Hash of options to customize the breadcrumb link.\n\n```ruby\nclass MyController\n  def index\n    add_breadcrumb \"index\", index_path, title: \"Back to the Index\"\n  end\nend\n```\n\nIn your view, you can render the breadcrumb menu with the `render_breadcrumbs` helper.\n\n```html\n\u003c!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n  \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"\u003e\n\u003chtml xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/\u003e\n  \u003ctitle\u003euntitled\u003c/title\u003e\n\u003c/head\u003e\n\n\u003cbody\u003e\n  \u003c%= render_breadcrumbs %\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n`render_breadcrumbs` understands a limited set of options. For example, you can pass change the default separator with the `:separator` option.\n\n```html\n\u003cbody\u003e\n  \u003c%= render_breadcrumbs :separator =\u003e ' / ' %\u003e\n\u003c/body\u003e\n```\n\nCurrent possible options are:\n\n- `:separator`\n- `:tag`\n\nTo use with Bootstrap you might use the following:\n\n```html\n\u003cbody\u003e\n  \u003col class=\"breadcrumb\"\u003e\n    \u003c%= render_breadcrumbs :tag =\u003e :li, :separator =\u003e \"\" %\u003e\n  \u003c/ol\u003e\n\u003c/body\u003e\n```\n\nMore complex customizations require a custom `Builder`.\n\n### HTML Escaping\n\nThe text of the breadcrumb is html-escaped by default unless it is a SafeBuffer, to prevent XSS attacks.\n\n```ruby\nclass MyController\n  add_breadcrumb \"This is the \u003cb\u003eMain\u003c/b\u003e page\".html_safe\n\n  def profile\n    add_breadcrumb \"#{@user_name} Profile\", users_profile\n  end\nend\n```\n\nIn this case, if `@user_name` is `\u003cscript\u003e`, it will output:\n\n```\nThis is the \u003cb\u003eMain\u003c/b\u003e page \u003e \u0026lt;script\u0026gt; Profile\n```\n\n\n### Breadcrumb Element\n\nA breadcrumbs menu is composed by a number of `Element` objects. Each object contains two attributes: the name of the breadcrumb and the target path.\n\nWhen you call `add_breadcrumb`, the method automatically creates a new `Element` object for you and append it to the breadcrumbs stack. `Element` name and path can be one of the following Ruby types:\n\n- `Symbol`\n- `Proc`\n- `String`\n\n#### Symbol\n\nIf the value is a `Symbol`, the library calls the corresponding method defined in the same context the and sets the `Element` attribute to the returned value.\n\n```ruby\nclass MyController\n  \n  # The Name is set to the value returned by\n  # the :root_name method.\n  add_breadcrumb :root_name, \"/\"\n  \n  protected\n  \n    def root_name\n      \"the name\"\n    end\n  \nend\n```\n\n#### Proc\n\nIf the value is a `Proc`, the library calls the proc passing the current view context as argument and sets the `Element` attribute to the returned value. This is useful if you want to postpone the execution to get access to some special methods/variables created in your controller action.\n\n```ruby\nclass MyController\n\n  # The Name is set to the value returned by\n  # the :root_name method.\n  add_breadcrumb Proc.new { |c| c.my_helper_method },\n                 \"/\"\n\nend\n```\n\n#### String\n\nIf the value is a `String`, the library sets the `Element` attribute to the string value.\n\n```ruby\nclass MyController\n\n  # The Name is set to the value returned by\n  # the :root_name method.\n  add_breadcrumb \"homepage\", \"/\"\n\nend\n```\n\n### Restricting breadcrumb scope\n\nThe `add_breadcrumb` method understands all options you are used to pass to a Rails controller filter. In fact, behind the scenes this method uses a `before_filter` to store the tab in the `@breadcrumbs` variable.\n\nTaking advantage of Rails filter options, you can restrict a tab to a selected group of actions in the same controller.\n\n```ruby\nclass PostsController \u003c ApplicationController\n  add_breadcrumb \"admin\", :admin_path\n  add_breadcrumb \"posts\", :posts_path, only: [:index, :show]\nend\n\nclass ApplicationController \u003c ActionController::Base\n  add_breadcrumb \"admin\", :admin_path, if: :admin_controller?\n  \n  def admin_controller?\n    self.class.name =~ /^Admin(::|Controller)/\n  end\nend\n```\n\n### Internationalization and Localization\n\n\u003ctt\u003eBreadcrumbsOnRails\u003c/tt\u003e is compatible with the standard Rails internationalization framework.\n\nFor example, if you want to localize your menu, define a new breadcrumbs node in your `.yml` file with all the keys for your elements.\n\n```yaml\n# config/locales/en.yml\nen:\n  breadcrumbs:\n    homepage: Homepage\n    first: First\n    second: Second\n    third: Third\n\n# config/locales/it.yml\nit:\n  breadcrumbs:\n    homepage: Homepage\n    first: Primo\n    second: Secondo\n    third: Terzo\n```\n\nIn your controller, use the `I18n.t` method.\n\n```ruby\nclass PostsController \u003c ApplicationController\n  add_breadcrumb I18n.t(\"breadcrumbs.first\"),  :first_path\n  add_breadcrumb I18n.t(\"breadcrumbs.second\"), :second_path, only: [:second]\n  add_breadcrumb I18n.t(\"breadcrumbs.third\"),  :third_path,  only: [:third]\nend\n\nclass ApplicationController \u003c ActionController::Base\n  add_breadcrumb I18n.t(\"breadcrumbs.homepage\"), :root_path\nend\n```\n\n\n## Support\n\nLibrary documentation is auto-generated from the [README](https://github.com/weppos/breadcrumbs_on_rails/blob/master/README.md) and the source code, and it's available at https://rubydoc.info/gems/breadcrumbs_on_rails.\n\n- The bug tracker is here: https://github.com/weppos/breadcrumbs_on_rails/issues\n- The code repository is here: https://github.com/weppos/breadcrumbs_on_rails. Contributions are welcome! Please include tests and/or feature coverage for every patch, and create a topic branch for every separate change you make.\n\n**Commercial support available as part of the Tidelift Subscription** - [Learn more](https://tidelift.com/subscription/pkg/rubygems-breadcrumbs.on.rails?utm_source=rubygems-breadcrumbs-on-rails\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo)\n\nThe maintainers of breadcrumbs_on_rails and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Consider subscribing to Tidelift which provides Enterprise support for this project.](https://tidelift.com/subscription/pkg/rubygems-breadcrumbs.on.rails?utm_source=rubygems-breadcrumbs-on-rails\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo)\n\n\n## Credits\n\n\u003ctt\u003eBreadcrumbsOnRails\u003c/tt\u003e was created and is maintained by [Simone Carletti](http://simonecarletti.com/). Many improvements and bugfixes were contributed by the [open source community](https://github.com/weppos/breadcrumbs_on_rails/graphs/contributors).\n\n\n## Security and Vulnerability Reporting\n\nFull information and description of our security policy please visit [SECURITY.md](SECURITY.md)\n\n\n## Changelog\n\nSee the [CHANGELOG.md](CHANGELOG.md) file for details.\n\n\n## License\n\nCopyright (c) 2009-2020 Simone Carletti. This is Free Software distributed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweppos%2Fbreadcrumbs_on_rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweppos%2Fbreadcrumbs_on_rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweppos%2Fbreadcrumbs_on_rails/lists"}