{"id":17038638,"url":"https://github.com/wbotelhos/breadcrumby","last_synced_at":"2026-05-10T03:02:34.434Z","repository":{"id":59151670,"uuid":"89444830","full_name":"wbotelhos/breadcrumby","owner":"wbotelhos","description":":bread: A solid Breadcrumb for Rails","archived":false,"fork":false,"pushed_at":"2018-01-08T17:21:06.000Z","size":65,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-25T00:42:49.662Z","etag":null,"topics":["breadcrumb","breadcrumb-navigation","breadcrumb-trail","breadcrumbs","rails"],"latest_commit_sha":null,"homepage":"","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/wbotelhos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-26T06:14:01.000Z","updated_at":"2017-05-08T20:38:22.000Z","dependencies_parsed_at":"2022-09-13T09:11:33.447Z","dependency_job_id":null,"html_url":"https://github.com/wbotelhos/breadcrumby","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wbotelhos/breadcrumby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbotelhos%2Fbreadcrumby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbotelhos%2Fbreadcrumby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbotelhos%2Fbreadcrumby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbotelhos%2Fbreadcrumby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wbotelhos","download_url":"https://codeload.github.com/wbotelhos/breadcrumby/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbotelhos%2Fbreadcrumby/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265534762,"owners_count":23783884,"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":["breadcrumb","breadcrumb-navigation","breadcrumb-trail","breadcrumbs","rails"],"created_at":"2024-10-14T08:57:20.121Z","updated_at":"2026-05-10T03:02:34.337Z","avatar_url":"https://github.com/wbotelhos.png","language":"Ruby","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=X8HEP2878NDEG\u0026item_name=breadcrumby"],"categories":[],"sub_categories":[],"readme":"# Breadcrumby\n\n[![Build Status](https://travis-ci.org/wbotelhos/breadcrumby.svg)](https://travis-ci.org/wbotelhos/breadcrumby)\n[![Gem Version](https://badge.fury.io/rb/breadcrumby.svg)](https://badge.fury.io/rb/breadcrumby)\n\nA solid Breadcrumb for Rails.\nYou do not need to dirty your controllers with a bunch of code.\nBreadcrumby is a really relational breadcrumb.\n\n## Install\n\nAdd the following code on your `Gemfile` and run `bundle install`:\n\n```ruby\ngem 'breadcrumby'\n```\n\n## Usage\n\nWith the following example of `ActiveRecord` relations:\n\n```ruby\nclass School\n  def show_path\n    \"/schools/#{id}\"\n  end\nend\n```\n\n```ruby\nclass Course\n  belongs_to :school\n\n  def show_path\n    \"/courses/#{id}\"\n  end\nend\n```\n\nLet's make it know about the breadcrumb path:\n\n```ruby\nclass School\n  breadcrumby\n\n  def show_path\n    \"/schools/#{id}\"\n  end\nend\n```\n\nNow school knows how to buid the breadcrumb but since it has no `path` it will be the last item.\n\nSo, we need to teach the Course class how to follow the path until School:\n\n```ruby\nclass Course\n  breadcrumby path: :school\n\n  belongs_to :school\n\n  def show_path\n    \"/courses/#{id}\"\n  end\nend\n```\n\nNow Breadcrumby know how to fetch the path, using the `belongs_to` relation.\n\n## View\n\nWith a instance of Course that has a relation with School, we can build the breadcrumb:\n\n```ruby\n\u003c%= breadcrumby @course %\u003e\n```\n\nAnd the result will be: `Home / School / Course`\n\n## HTML\n\nBreadcrumby uses the [semantic Breadcrumb HTML from Google](https://developers.google.com/search/docs/data-types/breadcrumbs):\n\n```html\n\u003col class=\"breadcrumby\" itemscope itemtype=\"http://schema.org/BreadcrumbList\"\u003e\n  \u003cli itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\"\u003e\n    \u003ca itemprop=\"item\" itemscope itemtype=\"http://schema.org/Thing\" title=\"{name}\" href=\"{show_path}\"\u003e\n      \u003cspan itemprop=\"name\"\u003e{name}\u003c/span\u003e\n    \u003c/a\u003e\n\n    \u003cmeta content=\"1\" itemprop=\"position\"\u003e\n  \u003c/li\u003e\n\u003c/ol\u003e\n```\n\n- `name`: Fetched from method `name` of the model;\n- `show_path`: Fetched from method `show_path` of the model.\n\n\u003e [I18n](I18n) configuration will always has priority over the model method.\n\n## Home\n\nAs you could see, the Home crumb was generated automatically.\nYou can customize the name with `I18n` and the `show_path` will be `root_path` or `/` by default.\n\n## Action\n\nYou can add one last path on breadcrumb to indicate the current action you are doing, like a edition:\n\n```ruby\nclass School\n  breadcrumby action: :edit\nend\n```\n\nIt generates a muted link on the end: `Home / School / Edition`\n\n```ruby\n\u003col class=\"breadcrumby\" itemscope itemtype=\"http://schema.org/BreadcrumbList\"\u003e\n  \u003cli itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\"\u003e\n    \u003ca itemprop=\"item\" itemscope itemtype=\"http://schema.org/Thing\" title=\"Edition\" href=\"javascript:void(0);\"\u003e\n      \u003cspan itemprop=\"name\"\u003eEdition\u003c/span\u003e\n    \u003c/a\u003e\n\n    \u003cmeta content=\"3\" itemprop=\"position\"\u003e\n  \u003c/li\u003e\n\u003c/ol\u003e\n```\n\nAll actions without `actions` option will try to follow `path` options.\nIf it is a new object, it will have no relation and will raise error.\n\n### Custom Action Path\n\nFor actions like `new` where the object will be a `new_record`, we can customize the candidate to represent the self object.\nThis way we can build a minimum path, not just `Home / New`.\nLet's say you have `Unit` on session and wants to set it on breadcrumb to say you are creating a `Course` on that unit of your school:\n\n```ruby\nclass Course\n  breadcrumby actions: {\n    new: -\u003e (view) { Unit.find(view.session[:current_school][:id])\n  }\nend\n```\n\nNow the `self` object will be the `new` call result and the output will be:\n\n```ruby\nHome / School / Unit / Courses / New\n```\n\nAs you can see, the path will be completed from the `self` (new result) object.\nPlus, since the new object is not `Unit`, we need a context. It will be related with original model with value of `index_path` as path:\n\n```ruby\n\u003ca itemprop=\"item\" itemscope=\"itemscope\" itemtype=\"http://schema.org/Thing\" title=\"List Courses\" href=\"/courses\"\u003e\n  \u003cspan itemprop=\"name\"\u003eTurmas\u003c/span\u003e\n\u003c/a\u003e\n```\n\nNow it is possible to navigate to collection of items you want to create a new one.\n\n## I18n\n\nYou can customize some attributes via I18n to be fast and global:\n\n```yaml\nen-US:\n  breadcrumby:\n    home:\n      name: Home\n      title: Home Page\n\n    school:\n      name: School\n      title: \"School: %{name}\"\n\n      actions:\n        edit: # new / index / method_name ...\n          name: Edition\n          title: \"Editing: %{name}\"\n```\n\n- `actions`: Properties to change the actions crumb;\n- `name`: The name of the crumb item;\n- `title`: The title of the crum item with possibility of to use the name `%{name}`.\n\nYou can change the model key name, since the default search is the class method name:\n\n```ruby\nclass School\n  breadcrumby i18n_key: :school_key\nend\n```\n\nAnd now use:\n\n```yaml\nen-US:\n  breadcrumby:\n    school_key:\n      name: School\n```\n\nTo make translations more generic just take it of inside the model name and it will be used for all models:\n\n```yaml\nen-US:\n  breadcrumby:\n    actions:\n      edit:\n        name: Edition\n```\n\n## Love it!\n\nVia [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=X8HEP2878NDEG\u0026item_name=breadcrumby) or [Gittip](http://www.gittip.com/wbotelhos). Thanks! (:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwbotelhos%2Fbreadcrumby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwbotelhos%2Fbreadcrumby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwbotelhos%2Fbreadcrumby/lists"}