Module: Releaf::ActionController::Breadcrumbs

Extended by:
ActiveSupport::Concern
Included in:
Releaf::ActionController
Defined in:
app/lib/releaf/action_controller/breadcrumbs.rb

Instance Method Summary collapse

Instance Method Details

#add_resource_breadcrumb(resource, url = nil) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
# File 'app/lib/releaf/action_controller/breadcrumbs.rb', line 16

def add_resource_breadcrumb(resource, url = nil)
  if resource.new_record?
    name=  I18n.t('New record', scope: 'admin.breadcrumbs')
    url = url_for(action: :new, only_path: true) if url.nil?
  else
    url_action = feature_available?(:show) ? :show : :edit
    name = Releaf::ResourceBase.title(resource)
    url = url_for(action: url_action, id: resource.id, only_path: true) if url.nil?
  end
  @breadcrumbs << { name: name, url: url }
end

#build_breadcrumbsObject


8
9
10
# File 'app/lib/releaf/action_controller/breadcrumbs.rb', line 8

def build_breadcrumbs
  @breadcrumbs = [controller_breadcrumb].compact
end

#controller_breadcrumbObject


12
13
14
# File 'app/lib/releaf/action_controller/breadcrumbs.rb', line 12

def controller_breadcrumb
  {name: definition.localized_name, url: definition.path} if definition
end