36 lines
1.4 KiB
Plaintext
36 lines
1.4 KiB
Plaintext
- model = controller_path.classify.constantize rescue nil
|
|
- if model
|
|
- object = model.find_by(id: params[:id])
|
|
- if model.try(:nested_resource?)
|
|
- root_element = model.model_name.human(count: 2)
|
|
- if object
|
|
- current_element = object
|
|
- else
|
|
- root_element = link_to_if(current_user && policy(model).index?, model.model_name.human(count: 2), send(:"#{model.model_name.collection}_path"))
|
|
- if object
|
|
- current_element = link_to_if(current_user && policy(object).show?, object, send(:"#{model.model_name.singular}_path", object))
|
|
- if I18n.exists?("shared.#{params[:action]}")
|
|
- active_action = t("shared.#{params[:action]}", model: model&.model_name&.human)
|
|
- else
|
|
- active_action = t("#{controller_name}.index.#{params[:action]}", model: model&.model_name&.human)
|
|
- else
|
|
- active_action = t("breadcrumbs.#{controller_name}.#{params[:action]}")
|
|
|
|
|
|
- title = "#{active_action} - #{application_name}"
|
|
- content_for :breadcrumbs do
|
|
.container.mb-4
|
|
ul.breadcrumb.bg-light.px-3.py-2
|
|
- if root_element.present?
|
|
li.breadcrumb-item.small
|
|
= root_element
|
|
- if current_element.present?
|
|
li.breadcrumb-item.small
|
|
= current_element
|
|
- title = "#{object} - #{title}"
|
|
- else
|
|
- title = "#{model.model_name.human(count: 2)} - #{title}"
|
|
li.breadcrumb-item.active.small
|
|
= active_action
|
|
- content_for :title, title
|