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
它还说默认显示包括当前用户的电子邮件地址.它是如何获得当前用户的电子邮件地址的?当我尝试用current_admin_user替换menu.add标签值时,我收到一条错误,指出current_admin_user未定义.如何从配置文件中访问有关当前登录用户的信息? ActiveAdmin在幕后如何做到这一点?
解决方法
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