gpt4 book ai didi

ruby-on-rails-4 - Rails 4/ActiveSupport : Circular dependency detected while autoloading constant User

转载 作者:行者123 更新时间:2023-12-04 07:19:36 24 4
gpt4 key购买 nike

运行后:

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

我试过关注 this post's advice : Circular dependency detected while autoloading constant User ,但不幸的是,据我所知,activesupport 没有可以发布问题或查看是否已解决的 github。

谢谢你的时间!

最佳答案

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

另外 - 检查你的用户 Controller 的第一行......它应该是:

类 UsersController < ApplicationController

之前有人遇到过这个错误,因为他们使用的是“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

关于ruby-on-rails-4 - Rails 4/ActiveSupport : Circular dependency detected while autoloading constant User,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18345462/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com