3

所以我想创建一个应用程序,人们可以在其中查看艺术。问题是,只有管理员才能创建、编辑和删除数据。所以我想添加一个管理界面。我选择了 rails_admin gem。

我已经按照 git 文档中的说明安装了所有东西,但是当我安装它时一切都停止了。我无法生成脚手架、模型或控制器,也无法启动我的服务器。每当我尝试某事时,它都会给我这个信息。

/Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:229:in `block in constantize': uninitialized constant Admin (NameError)
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:228:in `each'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:228:in `constantize'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/lib/devise.rb:256:in `get'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/lib/devise/mapping.rb:77:in `to'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/lib/devise/mapping.rb:72:in `modules'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/lib/devise/mapping.rb:89:in `routes'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/lib/devise/mapping.rb:156:in `default_used_route'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/lib/devise/mapping.rb:66:in `initialize'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/lib/devise.rb:290:in `new'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/lib/devise.rb:290:in `add_mapping'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/lib/devise/rails/routes.rb:208:in `block in devise_for'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/lib/devise/rails/routes.rb:207:in `each'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/lib/devise/rails/routes.rb:207:in `devise_for'
from /Users/Max/Desktop/walls/config/routes.rb:18:in `block in <top (required)>'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:in `eval_block'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:260:in `draw'
from /Users/Max/Desktop/walls/config/routes.rb:1:in `<top (required)>'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `each'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/file_update_checker.rb:78:in `call'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/file_update_checker.rb:78:in `execute'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:27:in `updater'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/Max/Desktop/walls/config/environment.rb:5:in `<top (required)>'
from /Users/Max/Desktop/walls/config.ru:4:in `block in <main>'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /Users/Max/Desktop/walls/config.ru:1:in `new'
from /Users/Max/Desktop/walls/config.ru:1:in `<main>'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/server.rb:46:in `app'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in `start'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:55:in `block in <top (required)>'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap'
from /Users/Max/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

在安装 rails_admin 之前,我已经设置了所有数据,所以如果我不得不重新开始,那就太糟糕了。

如果有人需要更多信息,我很乐意提供,但我现在不知道该发布什么。

4

2 回答 2

1

看看你的routes.rb,我必须有一些像这样的代码 devise_for :admin_users, ActiveAdmin::Devise.config

删除它或删除它。您已经删除了管理员,但可能尚未修改路由。

于 2013-04-10T08:11:57.760 回答
0

要再次回到工作项目状态,请从 Gemfile 中删除 gem 'rails_admin' 声明,从 config/initializers 目录中删除 rails_admin.rb 文件,然后从 config/routes.rb 中删除 rails_admin 生成的路由:

devise_for :admins
mount RailsAdmin::Engine => '/rails_admin', :as => 'rails_admin'

这就是导致 Devise 寻找 Admin 模型的原因。删除它,连同删除 gem 和初始化文件应该从你的项目中删除整个东西。

于 2012-12-12T16:54:43.760 回答