我从未使用过 MongoDB,并且正在使用其他人的代码,尝试使用 rails_admin gem。当我运行 rails g rails_admin:install 时,我得到以下日志:
- Hello, RailsAdmin installer will help you set things up!
- I need to work with Devise, let's look at a few things first:
- Checking for a current installation of devise...
- Found it!
- Looks like you've already installed it, good!
? Where do you want to mount rails_admin? Press <enter> for [admin] >
gsub config/routes.rb
route mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
- And you already set it up, good! We just need to know about your user model name...
- We found 'user' (should be one of 'user', 'admin', etc.)
? Correct Devise model name if needed. Press <enter> for [user] > admin
- Now setting up devise with user model name 'admin':
generate devise
/Users/sararobinson/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
invoke mongoid
create app/models/admin.rb
invoke test_unit
create test/unit/admin_test.rb
create test/fixtures/admins.yml
insert app/models/admin.rb
insert app/models/admin.rb
route devise_for :admins
- Now you'll need an initializer...
create config/initializers/rails_admin.rb
[RailsAdmin] Could not load model App::Models::Mongoid::GridFs, assuming model is non existing. (uninitialized constant App)
[RailsAdmin] Could not load model App::Models::Mongoid::GridFs::Fs::Chunk, assuming model is non existing. (uninitialized constant App)
[RailsAdmin] Could not load model App::Models::Mongoid::GridFs::Fs::File, assuming model is non existing. (uninitialized constant App)
[RailsAdmin] Could not load model Mongoid-gridFs, assuming model is non existing. (wrong constant name Mongoid-gridFs)
- Adding a migration...
- uninitialized constant RailsAdmin::Generators::Utils::ClassMethods::ActiveRecord
- Job's done: migrate, start your server and visit '/admin'!
然后,当我尝试从控制台添加管理员时,我收到此错误:
NameError: uninitialized constant Admin
让我知道我是否应该包含任何其他文件。我对 mongo 和 rails_admin 完全陌生,因此感谢您的帮助!