Module: Breadcrumble::ActionController::ClassMethods

Defined in:
lib/breadcrumble/action_controller.rb

Instance Method Summary collapse

Instance Method Details

#add_breadcrumb(name, url = nil, filter_options = {}) ⇒ Object

Add a breadcrumb.

Examples:

add_breadcrumb("home", home_url)
add_breadcrumb(-> context { context.title }, -> context { context.sample_path })

Parameters:

  • filter_options (defaults to: {})

    filter_options passed before_action method


15
16
17
18
19
# File 'lib/breadcrumble/action_controller.rb', line 15

def add_breadcrumb(name, url = nil, filter_options = {})
  before_action(filter_options) do |controller|
    controller.send(:add_breadcrumb, name, url)
  end
end

#add_breadcrumb_to(name, url, trail_index, filter_options = {}) ⇒ Object

Add a breadcrumb to breadcrumb trail.

Examples:

add_breadcrumb_to("level 1", "level 1 url", 0, only: :show)

Parameters:

  • trail_index

    index of breadcrumb trail

  • filter_options (defaults to: {})

    filter_options passed before_action method


26
27
28
29
30
# File 'lib/breadcrumble/action_controller.rb', line 26

def add_breadcrumb_to(name, url, trail_index, filter_options = {})
  before_action(filter_options) do |controller|
    controller.send(:add_breadcrumb_to, name, url, trail_index)
  end
end

#add_breadcrumbs(*args) ⇒ Object


32
33
34
35
36
37
38
# File 'lib/breadcrumble/action_controller.rb', line 32

def add_breadcrumbs(*args)
  before_action do |controller|
    args.each do |arg|
      controller.send(:add_breadcrumb, arg[0], arg[1])
    end
  end
end