ActiveAdmin文档说我可以像这样覆盖实用程序导航:
ActiveAdmin.setup do |config|
config.namespace :admin do |admin|
admin.build_menu :utility_navigation do |menu|
menu.add label: "ActiveAdmin.info", url: "http://www.activeadmin.info", html_options: { target: :blank }
admin.add_logout_button_to_menu menu # can also pass priority & html_options for link_to to use
end
end
end
它还说默认显示包括当前用户的电子邮件地址。它是如何获得当前用户的电子邮件地址的?当我尝试用menu.add label
替换current_admin_user
值时,我收到一条错误消息,指出current_admin_user
未定义。如何从配置文件中访问有关当前登录用户的信息? ActiveAdmin在幕后如何做到这一点?
答案 0 :(得分:10)
config.namespace :admin do |admin|
admin.build_menu :utility_navigation do |menu|
menu.add :label => proc{ display_name current_active_admin_user },
:url => proc{ edit_admin_admin_user_path(current_active_admin_user) } ,#link_to current_active_admin_user,
:id => 'current_user',
:if => proc{ current_active_admin_user? }
admin.add_logout_button_to_menu menu
end
end
答案 1 :(得分:3)
试试以下内容:
ActiveAdmin.setup do |config|
config.namespace :admin do |admin|
admin.build_menu :utility_navigation do |menu|
menu.add label: "ActiveAdmin.info", url: "http://www.activeadmin.info",
html_options: { target: :blank }
admin.add_current_user_to_menu menu
admin.add_logout_button_to_menu menu
end
end
end