richiepop2
richiepop2

Reputation: 348

Link to user account from active admin

I'd like to create a link from active admin to my user edit page. I searched online here, but couldn't find anything that referenced creating links for specific users. I'm guessing I'd add some code to the admin_user.rb page, but just unclear what I would need to add. Also, would the active admin need permissions in order to get into a user's edit page, since this page is behind username and password? Any help would be great appreciated.

Upvotes: 0

Views: 737

Answers (1)

romainsalles
romainsalles

Reputation: 2143

You can add these lines in config/initializers/active_admin.rb:

ActiveAdmin.setup do |config|
  config.namespace :activeadmin do |admin|

    admin.build_menu :utility_navigation do |menu|

      user_menu = menu.add  label: proc { current_admin_user.email },
                              url: proc { edit_activeadmin_admin_user_url(current_active_admin_user.id) },
                               id: 'current_user',
                               if:  proc { current_active_admin_user } # Check the permissions here
      admin.add_logout_button_to_menu user_menu, 100
    end
  end
end

Upvotes: 2

Related Questions