alexeysh
alexeysh

Reputation: 65

ActiveAdmin Show current menu structure in page

I got resource and pages structure with this code

resource_collection = ActiveAdmin.application.namespaces[:admin].resources

from here

Resource has a hash menu_item_options with id, label, url, if, parent.

I tried in rails console

resource_collection.first.menu_item_options[:parent]

and it is filled, but inside my page it is blank.

How I can get ActiveAdmin menu structure in ActiveAdmin page?

Upvotes: 2

Views: 513

Answers (1)

Piers C
Piers C

Reputation: 2978

The default menu is available via

ActiveAdmin.application.namespaces[:admin].fetch_menu(:default)

Items are displayed if item.should_display evaluates to true. By default for a resource item this is based on whether the current user is authorized to read the resource, but it can be overridden with the item if: option. If no menu items are displayed most likely it is an authorization issue.

Upvotes: 2

Related Questions