如何在导航标题中显示current_admin_user的名称?

时间:2016-12-20 10:03:37

标签: ruby-on-rails-4 activeadmin

建设如:

  menu.add :label => current_admin_user.full_name do |submenu|
    menus.each do |m|
      submenu.add :label => m['name'],
                  :url => "/admin/change/#{m['id']}",
                  :html_options => {:style => 'float:left;'},
                  :if => proc { current_admin_user.role?('super_admin') }
    end
  end

不再适用于1.0pre +。范围中没有current_admin_user。但是在日志中,我看到在添加菜单之前获取管理员用户的请求。

SELECT  `admin_users`.* FROM `admin_users` WHERE `admin_users`.`id` = 6  ORDER BY `admin_users`.`id` ASC LIMIT 1

有机会处理它吗?

1 个答案:

答案 0 :(得分:0)

仍然可以使用,我只需要传递菜单的ID

  menu.add id: 'user_name' label: -> { current_admin_user.full_name } do |submenu|