问题
So i wanted to create an app, where people can view art. The problem is, only the admin should be able to create, edit and delete data. So i wanted to add an admin interface. I went with the rails_admin gem.
I've installed everything as it said on the git documentation, but everything stopped working when I installed it. I can't generate scaffolds, models or controllers and I can't start my server. It gives me this message whenever I try something.
/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>'
I already had all my data set up before I installed rails_admin, so it would be pretty bad if I had to start over.
If someone needs more info, I'd be glad to give it, but I have no idea what to post right now.
回答1:
Look at your routes.rb, there must me some code like this devise_for :admin_users, ActiveAdmin::Devise.config
remove it or delete it. You have already remove the admin but may haven't modify in routes.
回答2:
To get back to a working project state again, remove the gem 'rails_admin' declaration from your Gemfile, remove the rails_admin.rb file from your config/initializers directory and then remove the rails_admin generated route from config/routes.rb:
devise_for :admins
mount RailsAdmin::Engine => '/rails_admin', :as => 'rails_admin'
That is what is causing Devise to look for an Admin model. Removing that, along with removing the gem and initializer file should remove the whole thing from your project.
来源:https://stackoverflow.com/questions/11383367/installed-rails-admin-and-everything-stops-working