问题
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.
回答1:
Try restarting rails server. Had similar problems which cleared up after a restart.
回答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.
回答3:
Renaming app/models/admin_user.rb to app/models/admin_users.rb helped me.
来源:https://stackoverflow.com/questions/16905596/activeadmin-uninitialized-constant-adminuser