I have a couple of models in my Ruby on Rails application like "Plan", "Tester", "Module", etc. Using activeadmin gem, I would like to have a page for each of these entities and place each under a couple of different menus. So my code looks like the following:
ActiveAdmin.register Plan do
menu parent: 'Planning', priority: 1
ActiveAdmin.register Tester do
menu parent: 'Planning', priority: 2
ActiveAdmin.register Module do
menu parent: 'Bundle', priority: 1
ActiveAdmin.register User do
menu parent: 'Administration', priority: 1
I don't have a page for the top menus ('Planning', 'Bundle', 'Administration'), but I want to see them in a custom order and not the alphabetical order. So, my question is how could I set the priority (order) of the parent menus without having a corresponding page for each of them?
The items, which non model-based starts their priority from 10, so u can put 10+ priority for model-based menus. If you need to set priorities among non model-based menus, you can build fake file under admin folder like admin/administration.rb with code:
ActiveAdmin.register_page "Administration" do
menu :label => "Administration", :priority => 15, :url => '#'
end
and admin/bundle.rb:
ActiveAdmin.register_page "Bundle" do
menu :label => "Bundle", :priority => 16, :url => '#'
end
so on
See 'Customizing Parent Menu Items' in the documentation.
# config/initializers/active_admin.rb
config.namespace :admin do |admin|
admin.build_menu do |menu|
menu.add label: 'Blog', priority: 0
end
end
# app/admin/post.rb
ActiveAdmin.register Post do
menu parent: 'Blog'
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With