Socket
Book a DemoInstallSign in
Socket

breadcrumbs_for

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

breadcrumbs_for

0.2.3
bundlerRubygems
Version published
Maintainers
1
Created
Source

= breadcrumbs_for

Breadcrumbs Rails helper.

Breadcrumbs helper for Rails done in a rails way.

Built on url_for, your routes, model names and i18n.

== Installation gem install breadcrumbs_for

== Requirements Was tested with Rails 3

== Usage Let say:

  • You have a Blog and Post models in your app.
  • Posts are nested in Blogs.
  • You have :admin namespace to manage them.
  • Blog and Post have a 'title' or 'name' methods

===Examples: breadcrumbs_for :blogs # Home / Blogs breadcrumbs_for :blogs, 'new' # Home / Blogs / New breadcrumbs_for :blogs, @blog # Home / Blogs / My blog breadcrumbs_for :blogs, @blog, 'edit' # Home / Blogs / My blog / Edit breadcrumbs_for @blog # Home / My blog breadcrumbs_for :blogs, @blog, [@blog, @post] # Home / Blogs / My blog / My Post

breadcrumbs_for [:admin,:blogs], [:admin, @blog] breadcrumbs_for [:admin,:blogs], ['edit', :admin, @blog, @post] breadcrumbs_for [:admin,:blogs], [:admin, @blog], ['edit', :admin, @blog, @post]

etc.

Note: There is a shorter alias crumbs_for, so you can do: crumbs_for :blogs, @blog

You can even do the following: breadcrumbs_for {:controller=>'blogs', :action=>'index', :crumb=>'All Blogs'}, @blog Note on :crumb=>'All Blogs'. Here you need to provide the breadcrumb caption text directly via the :crumb key.

If you have an admin_path in your routes you can do: breadcrumbs_for :admin, [:admin,:blogs], ['new', :admin, @blog], :crumbs_options=>{:root=>false}

=== Produced HTML By default it will render breadcrumbs as an unordered list.

The following code

<%= crumbs_for :posts, 'New' %>

will produce html:

  • Home
  • /
  • Posts
  • /
  • New

You can also render bredcrumbs in plain.

The following code

<%= crumbs_for :posts, 'New', :crumbs_options => { :type => :plain } %>

will produce html:

Home / Themes / New

=== Customize

  • Don't inculde the Home(root) link: breadcrumbs_for :blogs, @blog, :crumbs_options=>{:root=>false}
  • By default breadcrumbs are rendered as a ul(html unorderd list). You can disable this: breadcrumbs_for :blogs, @blog, :crumbs_options=>{:type=>:plain}
  • The default separator is /. Chage it: breadcrumbs_for :blogs, @blog, :crumbs_options=>{:sep=>'→'}

=== Custom captions and i18n Define captions for breadcrumbs in your locale file: en: breadcrumbs: root: 'Home' actions: new: 'Add new' edit: 'Edit one' names: admin: 'Manage' blogs: 'The blogs' posts: 'The posts'

=== Tips & Tricks When providing action as a String it will include action name in breadcrumb caption.

crumbs_for :blogs, ['edit', @blog] # => Home / Blogs / Edit My blog

When providing action as a Symbol it will skip action name in breadcrumb caption.

crumbs_for :blogs, [:edit, @blog] # => Home / Blogs / My blog

== Note on Patches/Pull Requests

Patches/Pull Requests are welcome!

  • Fork the project.
  • Make your feature addition or bug fix.
  • Commit.
  • Send a pull request.

== Copyright

Copyright (c) 2010 Dmitry Naumov. Released under the MIT license. See LICENSE for details.

FAQs

Package last updated on 21 Nov 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.