<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <% num_parts_to_reject = %w(show edit new).include?(action_name) ? 2 : 1 %>
    <% path_parts = request.path.split('/').reject(&:blank?) %>
    <% path_parts.each_with_index do |path_part, index| %>
      <% path_part_name = path_part == 'admin' ? 'dashboard' : path_part %>
      <% if index >= num_parts_to_reject || num_parts_to_reject == path_parts.length %>
        <li class="breadcrumb-item active" aria-current="page">
          <%= path_part_name.titleize %>
        </li>
      <% else %>
        <% if recognize_path(path_parts[0..index].join('/').prepend('/')) %>
          <li class="breadcrumb-item">
            <%= link_to path_part_name.titleize, path_parts[0..index].join('/').prepend('/') %>
          </li>
        <% else %>
          <li class="breadcrumb-item active">
            <%= path_part_name.titleize %>
          </li>
        <% end %>
      <% end %>
    <% end %>
  </ol>
</nav>

<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <% num_parts_to_reject = %w(show edit new).include?(action_name) ? 2 : 1 %>
    <%# Check for namespaced controllers %>
    <% path_parts = request.path.split('/').reject(&:blank?) %>
    <% if controller.class.name.split('::').length == 3 %>
      <% path_parts = [path_parts[0], path_parts.slice(1..2).join('/'), *path_parts[3..]] %>
    <% end %>
    <% path_parts.each_with_index do |path_part, index| %>
      <% path_part_name = path_part == 'admin' ? 'dashboard' : path_part %>
      <% path_part_name_components = path_part_name.split('/') %>
      <% path_part_name = path_part_name_components.length > 1 ? ("[#{path_part_name_components.first.titleize}] #{path_part_name_components.last.titleize}") : path_part_name_components.first.titleize %>
      <% if index >= num_parts_to_reject || num_parts_to_reject == path_parts.length %>
        <li class="breadcrumb-item active" aria-current="page">
          <%= path_part_name %>
        </li>
      <% else %>
        <% if recognize_path(path_parts[0..index].join('/').prepend('/')) %>
          <li class="breadcrumb-item">
            <%= link_to path_part_name, path_parts[0..index].join('/').prepend('/') %>
          </li>
        <% else %>
          <li class="breadcrumb-item active">
            <%= path_part_name %>
          </li>
        <% end %>
      <% end %>
    <% end %>
  </ol>
</nav>

Update breadcrumbs partial to work better with namespaced controllers
Update breadcrumbs partial to work better with namespaced controllers
