ActiveAdmin - uninitialized constant AdminUser

14,605

Solution 1

Try restarting rails server. Had similar problems which cleared up after a restart.

Solution 2

This error will be thrown any time your model has an erroneous association in it. If you changed any associations, but forget to update your model's file, you will get this error.

Double check your model files. Open active admin locally to see what error it gives you (localhost:3000/admin). It will usually say uninitialized constant MyModel:MyBadAssociation, so helps you diagnose the error.

Share:
14,605

Related videos on Youtube

Author by

Benji Lanyado

Journalist turned trainee dev! I'm always amazed at the generosity of people on here. Again thanks.

Updated on October 15, 2022

Comments

  • Benji Lanyado 4 days

    I'm getting an error while trying to run my app, having recently installed ActiveAdmin. It was working fine, but, after idling for a while, suddenly it isn't!

    In my gem file:

    gem 'activeadmin'
    

    In my routes:

      devise_for :admin_users, ActiveAdmin::Devise.config
      ActiveAdmin.routes(self) 
    

    And in my admin_user.rb

    ActiveAdmin.register AdminUser do     
      index do                            
        column :email                     
        column :current_sign_in_at        
        column :last_sign_in_at           
        column :sign_in_count             
        default_actions                   
      end   etc....
    

    The error when trying to run:

    NameError: uninitialized constant AdminUser
    ~/Desktop/Sites/Fleetnation/app/admin/admin_user.rb:1:in `<top (required)>'
    /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:230:in `block in constantize'
    /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:229:in `each'
    /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:229:in `constantize'
    ...
    

    Anyone got any ideas? Would be much appreciated.

  • Benji Lanyado over 9 years
    Nope... doesn't fix it I'm afraid!
  • Nate Beers
    Nate Beers over 6 years
    No matter how many times I have run into this issue, I always forget to restart the server after installing a new gem. Then, I see an answer like this and I remember. Thanks.
  • Jayant Bhawal
    Jayant Bhawal over 6 years
    I can't believe that this was the fix. +1 for reminding that fixes can be simple too at times.