Module: BreadcrumbsHelper

Defined in:
app/helpers/breadcrumbs_helper.rb

Overview

View helper: breadcrumbs.

Instance Method Summary collapse

Instance Method Details

Returns link to the home page.

Returns:

  • (String)

    link to the home page



30
31
32
# File 'app/helpers/breadcrumbs_helper.rb', line 30

def breadcrumb_home
  link_to fa_icon('house'), cms_link('/')
end

#build_breadcrumb(*args) ⇒ Object

Build breadcrumb navigation with flexible argument support

Examples:
build_breadcrumb({ href: images_path, title: 'Images' }, { title: 'Edit Image Uploads' })
build_breadcrumb(@object, 'Edit')
build_breadcrumb('Edit Images Uploads') # Legacy support
build_breadcrumb({ href: customers_path, title: 'Customers' }, @customer, 'Edit')

Parameters:

  • args (Array)

    Variable number of arguments supporting:

    • Hash with :href and :title for linked breadcrumbs
    • Hash with only :title for active (non-linked) breadcrumbs
    • String for action/title text
    • Objects for automatic breadcrumb generation
    • nil values are ignored


19
20
21
22
23
24
25
26
27
# File 'app/helpers/breadcrumbs_helper.rb', line 19

def build_breadcrumb(*args)
  # A trailing Hash is presenter context (only `{ tab: … }` today, read by
  # BreadcrumbPresenter#build_for_product_line) — but ONLY when it isn't a
  # segment. Popping unconditionally silently swallowed the last segment of
  # every `build_breadcrumb(…, { title: 'New' })` call, which is the form the
  # examples above use and ~39 views rely on.
  context = args.last.is_a?(Hash) && !segment_hash?(args.last) ? args.pop : {}
  Crm::BreadcrumbPresenter.new(args, context).breadcrumb
end