简体   繁体   中英

rails_admin breaks everything, uninitialized constant Admin (NameError)

What I try to archieve

I am writing a rails app that is mostly CRUD. I want to have an admin interface so that non-programmers should be able to control the content. I decided to go with the ready-made library rails admin , because it seems to be the one that offers the most of convention > configuration.

What goes wrong

Well, mostly everything.

Everytime I run a command that uses the rails configuration (it seems) it halts and gives me a long error. The errors I get in my shells are posted here if you can understand it better than I do.

If I do another rails command, such as rails g model Admin it fails in the same manner, complaining uninitialized constant Admin (NameError) .

This is my Gemfile .

How it got this bad

I was strolling along, whistling and having a jolly time. Created a ruby application, installed Devise and set up the User class with it, scaffolded a few CRUD MVC's, made a few custom controllers-views. I know that the gem 'will_paginate' is in conflict with 'rails_admin', so I removed it from my gemfile and instead went with 'kaminari'.

Who I suspect

Erik . No, I'm sure he's great. But rails_admin obviously did not play nice with my app. I suspect this has something to do with me not creating an 'Admin' model before installing the gem. But I can't fix it now, since I get theese errors (and I get errors even if I remove rails_admin from the gemfile, do a bundle and then try to rails g ).

Have you removed 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM