有没有办法在Active Admin中创建多级菜单(两个以上的深度级别),而有些条目不是模型?
类似的东西:
1 - Some_text
1.1 - Model_1
1.1.1 - Model_2
1.2 - Some_other_text
1.2.1 - Model_3
1.2.2 - Model_4
1.3 - Model_5
2 - Some_more_text
2.1 - Model_6
2.2 - Model_7
3 - Model_8
我还没有办法做到这一点(我检查了宝石subnav,但它不允许我将纯文本作为菜单条目:它必须是模型)
欢迎任何建议。谢谢
答案 0 :(得分:1)
执行此操作的方法是创建一个ActiveAdmin::Views::Header
。
类似于以下内容:
class CustomAdminHeader < ActiveAdmin::Views::Header
include Rails.application.routes.url_helpers
def build(namespace, menu)
div class: 'c-nav' do
div class: 'logo' do
image_tag(image_url("logo.svg"))
end
div class: 'list' do
# Add one item without son.
ul do
# Replace route_destination_path for the route you want to follow when you receive the item click.
li { link_to 'Dashboard', admin_dashboard_path }
end
# Add one item with one son.
ul do
li do
text_node content_tag 'a', 'Animals'
ul do
li { link_to 'Cats', admin_cats_path }
li { link_to 'Dogs', admin_dogs_path }
li { link_to 'Wolves', admin_wolves_path }
li { link_to 'Cows', admin_cows_path }
li do
text_node content_tag 'a', 'Settings', class: '-with-children'
ul do
li { link_to 'Categories', admin_categories_path }
li { link_to 'Subcategories', admin_subcategories_path }
li { link_to 'Colors', admin_colors_path }
li { link_to 'Sizes', admin_sizes_path }
li { link_to 'Sounds', admin_sounds_path }
li { link_to 'Species', admin_species_index_path }
end
end
end
end
end
...