activeadmin: undefined method 'admin_user_url'

When trying to login to Active Admin, an exception is thrown…

NoMethodError in ActiveAdmin::Devise::SessionsController#create
undefined method `admin_user_url' for #<ActiveAdmin::Devise::SessionsController:0x007fa820e565d0>

I’m running Rails 3.2.1, Active Admin 0.4.3 and Devise 2.0.0

About this issue

  • Original URL
  • State: closed
  • Created 12 years ago
  • Comments: 22 (8 by maintainers)

Most upvoted comments

Never figured it out. Switched to https://github.com/sferik/rails_admin

Had the same problem, it solved itself when I restarted the server

Yep the solution was actually just to add a "super " in my after_sign_in_path_for method like that :

def after_sign_in_path_for(resource)
 if resource.respond_to? :profil      
   if current_user.profil.nil?        
     new_user_profil_url(current_user) 
   else                               
     home_path                         
   end                                
 else                                 
    super                              
 end                                  
end                                   

If this helps anyone, I was having the same issue and determined that it was because I had a User model in addition to the AdminUser model, where I was overriding the after sign in redirection as listed on Devise’s wiki. Adding @sandeep45’s code snippet fixed the issue for me:

    def after_sign_in_path_for(resource_or_scope)
      if resource_or_scope.is_a?(User)
        portal_path
      elsif resource_or_scope.is_a?(AdminUser) 
        admin_dashboard_path(resource_or_scope)
      end
    end

So i finally resolved this problem. It seems to be looking for admin_user_url but when i do rake routes, i don’t have any such route. All routes are admin_path like, there is no _user in the end. I verified my model name is AdminUser. So i am not sure why the routes are like admin_path and not admin_user_path. Either way to fix it in my after_sign_in_path_for i added:

    if resource_or_scope.is_a?(AdminUser) 
      admin_dashboard_path(resource_or_scope)
    end

this made sure it went to a path which exists? Can someone explain why are the routes named differently from what the model name is? thanks