我正在使用Active Admin并尝试在下拉菜单中添加其他级别.在文档中,我看到我可以使用此代码放置一个级别:
ActiveAdmin.register Post do menu :parent => "Blog" end
谢谢你的帮助.
编辑:
我想要这样的东西:
Menu 1 ^ Menu 2 > Menu A Menu B Menu 3
解决方法
我解决了这个问题,覆盖了ActiveAdmin的菜单.还需要为新菜单创建一个新的CSS.
通知ActiveAdmin我们将使用标头本身.为此,在config / initializers / active_admin.rb文件中添加以下行:
config.view_factory.header = CustomAdminHeader config.register_stylesheet 'new_menu.css'
创建一个名为CustomAdminHeader的类,该类将包含将覆盖构造菜单的代码.您可以在app / admin中创建此类,并将该文件命名为custom_admin_header.rb.并添加此代码以创建新菜单:
class CustomAdminHeader < ActiveAdmin::Views::Header include Rails.application.routes.url_helpers def build(namespace,menu) div :id => 'tabs' 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 'Item without son',route_destination_path } end # Add one item with one son. ul do li do text_node link_to("Parent with 1 child","#") ul do li { link_to 'Son without child',route_destination_path } # If you want to add more children,including more LIs here. end end end # Adds a menu item with one son and one grandson. ul do li do text_node link_to("Grandmother with 1 child","#") ul do li do text_node link_to("Parent with 1 child",route_destination_path) ul do li { link_to 'Grandson without child',route_destination_path } # If you want to add more grandchildren,including more LIs here. end end end end end super(namespace,menu) end end
菜单的结构将由此类创建,因此不应显示文件夹app / admin中包含的类中使用的菜单设置.为此,您需要在所有类中添加以下代码:
menu false
最后,您需要创建一个名为new_menu.css的CSS文件,并为新菜单添加CSS.
http://monteirobrena.wordpress.com/2013/05/07/activeadmin-customizacao-do-menu/
我希望它对任何人都有帮助.