6

运行后:

rails generate active_admin:resource Project

在终端我收到以下错误:

/Users/thalatta/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:460:in `load_missing_constant': Circular dependency detected while autoloading constant User (RuntimeError)
from /Users/thalatta/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:183:in `const_missing'
from /Users/thalatta/code/byrdtyme/app/admin/user.rb:1:in `<top (required)>'

这是我的 Gemfile 供参考:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'



gem 'launchy'

gem 'devise',              github: 'plataformatec/devise'
gem 'responders',          github: 'plataformatec/responders'
gem 'inherited_resources', github: 'josevalim/inherited_resources'
gem 'ransack'
gem 'activeadmin',         github: 'gregbell/active_admin', branch: 'rails4'
gem 'formtastic',          github: 'justinfrench/formtastic'

gem 'spork'

gem 'rspec-rails'

gem 'capybara', '1.1.2'

gem 'cancan'

#TODO figure out how to resolve this! don't werk with Rails 4
#gem 'audited-activerecord'


# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

gem 'rspec-rails'


gem 'factory_girl_rails', '~> 4.0'
gem 'faker'

gem 'haml'
# 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', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

我尝试遵循这篇文章的建议自动加载常量 User 时检测到循环依赖,但不幸的是,据我所知,activesupport 没有可以发布问题或查看问题是否已解决的 github。

谢谢你的时间!

4

1 回答 1

2

尝试删除第二次提及 gem 'rspec-rails'

另外 - 检查您的用户控制器的第一行......它应该是:

类用户控制器 < 应用控制器

之前有人遇到过这个错误,因为他们有 'UsersControllers' 而不是 UserController(参见这篇文章:Rails 4 Runtime error in controller: Circular dependency detected while autoloading constant)。

您的新 Gemfile 将如下所示:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

gem 'launchy'

gem 'devise',              github: 'plataformatec/devise'
gem 'responders',          github: 'plataformatec/responders'
gem 'inherited_resources', github: 'josevalim/inherited_resources'
gem 'ransack'
gem 'activeadmin',         github: 'gregbell/active_admin', branch: 'rails4'
gem 'formtastic',          github: 'justinfrench/formtastic'

gem 'spork'

gem 'rspec-rails'

gem 'capybara', '1.1.2'

gem 'cancan'

#TODO figure out how to resolve this! don't werk with Rails 4
# gem 'audited-activerecord'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

gem 'factory_girl_rails', '~> 4.0'
gem 'faker'
gem 'haml'
# 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', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end
于 2015-02-06T02:43:23.973 回答