Reputation: 303
I'm trying to create a drop down menu in active admin's navigation. The docs:
https://activeadmin.info/2-resource-customization.html#customize-the-menu
says all I need to do is create the menu:
config.namespace :admin do |admin|
admin.build_menu do |menu|
menu.add label: 'example', priority: 0
end
end
then add that menu as the parent of the resource:
menu parent: 'example'
But that doesn't work for me.
The only thing that has thus far is this:
config.namespace :admin do |admin|
admin.build_menu do |menu|
menu.add label: 'Appointment', priority: 0, html_options: { target: :blank } do |item|
item.add label: 'Appointment', url: '/admin/appointments'
item.add label: 'AppointmentCommunication', url: '/admin/appointment_communications'
end
end
end
With menu: false in the actual resource file.
But that's pretty messy, and not well organized. I was hoping to have a simpler way of making the menus. But maybe I'm just missing something.
Note: I did try to name the menu something that wasn't the name of one of the resources but alas no changes. Additionally, I tried moving the two resources - Appointment and AppointmentCommunication - into a folder called Appointment but obviously that didn't work.
Any thoughts on this would be appreciated.
Upvotes: 0
Views: 2723
Reputation: 713
A couple of options:
menu parent: 'site'
site
will become the dropdown name and resource(s) will be menu items.
initializers/active_admin.rb
:config.namespace :admin do |admin|
super_admin.site_title = "Active Admin"
admin.build_menu do |menu|
menu.add label: 'Configuration', priority: 0
end
end
One thing to note is, if you go with option #2, you have to restart your server in order to view the changes.
Source: https://activeadmin.info/2-resource-customization.html#customize-the-menu
Upvotes: 1
Reputation: 5038
It should work as in the docs
# app/admin/appointment.rb
menu label: 'Appointment', parent: 'Appointments', priority: 0
# app/admin/appointment_communication.rb
menu label: 'Appointment Communication', parent: 'Appointments', priority: 1
Upvotes: 0