Reputation: 930
I'm using ActiveAdmin
gem. I want to add a logout button in my utility_navigation menu. So in config/initializers/active_admin.rb
I write:
config.namespace :admin do |admin|
admin.build_menu :utility_navigation do |menu|
admin.add_logout_button_to_menu menu, html_options: {}
end
end
Then I refresh the page, but the menu looks strange:
When I move the cursor above the user icon, the menu pops up. But the position where there should be the user name is blank, and I can't move the cursor to the logout button (texted 退出
), because the cursor must move out of the icon.
I'm confused where is the user name row in the menu?
About the current user, I'm sure my current_user_method
gives the right username. Here are the related codes:
In active_admin.rb
:
config.current_user_method = :current_admin_user
And in application_controller.rb
:
def current_admin_user
puts "CURRENT_ADMIN_USER !!!!!"
user = current_admin()
if !user.nil?
puts user.name
user.name
else
puts "nil"
nil
end
end
When I refresh the page, I can see the username admin
printed in the console line. So I'm sure I give the right current_user_method
.
Can anyone help me? Thank you.
Upvotes: 0
Views: 749