Sha256: b35fad08bf43403087ed7fb629c640b660705835becd4f8842d6fd46eb4733e4

Contents?: true

Size: 862 Bytes

Versions: 6

Compression:

Stored size: 862 Bytes

Contents

module ActiveAdmin
  class BaseController < ::InheritedResources::Base
    module Menu
      extend ActiveSupport::Concern

      included do
        before_action :set_current_tab
        helper_method :current_menu
      end

      protected

      def current_menu
        active_admin_config.navigation_menu
      end

      # Set's @current_tab to be name of the tab to mark as current
      # Get's called through a before filter
      def set_current_tab
        @current_tab = if current_menu && active_admin_config.belongs_to? && parent?
          parent_item = active_admin_config.belongs_to_config.target.menu_item
          if current_menu.include? parent_item
            parent_item
          else
            active_admin_config.menu_item
          end
        else
          active_admin_config.menu_item
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
yousty-activeadmin-1.0.17.pre lib/active_admin/base_controller/menu.rb
yousty-activeadmin-1.0.16.pre lib/active_admin/base_controller/menu.rb
yousty-activeadmin-1.0.15.pre lib/active_admin/base_controller/menu.rb
activeadmin-1.0.0 lib/active_admin/base_controller/menu.rb
yousty-activeadmin-1.0.14.pre lib/active_admin/base_controller/menu.rb
yousty-activeadmin-1.0.13.pre lib/active_admin/base_controller/menu.rb