昨天学习同事代码,然后想着加个后台管理的 gem,activeadmin 这个试试,按这个流程加的, Installation
gem 'activeadmin'
# Plus integrations with:
gem 'devise'
gem 'cancancan'
gem 'draper'
gem 'pundit'
rails g active_admin:install User ----一开始我以为 user 是指用户名就输入了用户名 (rails g active_admin:install xxxx),后来发现不对,我也不晓得怎么回滚,就又 rails g active_admin:install User 然后
rake db:migrate ---不成功
rake db:seed
rails server ----就一直报图片里面的错了,大神能指点一下怎么处理呢?
想请教几个问题
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '5.0.0'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.15'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'activeadmin'
gem 'devise'
gem 'cancancan'
gem 'rolify'
gem 'draper'
gem 'pundit'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
gem 'bootstrap-sass', '~>3.3.7'
gem 'autoprefixer-rails', '~>5.2.1'
#gem "twitter-bootstrap-rails"
gem 'carrierwave', '>= 1.0.0.beta', '< 2.0'
gem 'rmagick'
gem 'grape'
gem 'doorkeeper'
gem "rack-oauth2"
#gem 'will_paginate', '~> 3.1.1'
gem 'kaminari'
gem 'dalli'
gem 'actionpack-page_caching'
gem 'actionpack-action_caching'
gem 'delayed_job'
gem 'delayed_job_active_record'
#gem "sidekiq"
#gem "devise-doorkeeper"
gem 'roadie'
gem 'roadie-rails'
gem 'nokogiri', '1.6.0'
#gem 'premailer-rails'
事实上在 rake db:migrate 时就报错了,in `load_missing_constant': Circular dependency detected while autoloading constant V1::Base (RuntimeError),完全看不懂什么情况啊
按你的描述,我在自己的 macOs 上搭建了一个 activeadmin 的调试环境:
sudo gem install rails --version '5.0.0'
rails _5.0.0_ new activeadmin_debug
故意做了一次失误操作:
$ rails g active_admin:install kyk
Running via Spring preloader in process 49761
invoke devise
generate No need to install devise, already done.
invoke active_record
create db/migrate/20190429081305_devise_create_kyks.rb
create app/models/kyk.rb
invoke test_unit
create test/models/kyk_test.rb
create test/fixtures/kyks.yml
insert app/models/kyk.rb
route devise_for :kyks
gsub app/models/kyk.rb
gsub config/routes.rb
append db/seeds.rb
create config/initializers/active_admin.rb
create app/admin
create app/admin/dashboard.rb
create app/admin/kyks.rb
insert config/routes.rb
generate active_admin:assets
你要回滚的话应该这么操作:1. 把 app/admin/kyks.rb 文件里的 kyk 改成 Kyk; 2. 把 config/routes.rb 文件里的:
devise_for :kyks, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
去掉
然后运行 rails destroy active_admin:install kyk
, 这样就可以了,注意用你自己填写的 xxx 代替我写的 kyk
后面的 rails g active_admin:install User
的操作我都可以正常运行了,可以参考下我上传的 demo: https://github.com/baya/activeadmin_debug
in `load_missing_constant': Circular dependency detected while autoloading constant V1::Base (RuntimeError)
这个说的是这里有循环依赖吧