Rails 4控制器中的运行时错误:自动加载常量时检测到循环依赖性

时间:2023-01-19 20:50:06

Let me know if I left anything out. I can't figure out why my views/references/ folder isn't accessible. neither new.html.erb nor index.html.erb is available. When I go to localhost:3000/references my error is:

如果我遗漏了任何东西,请告诉我。我无法弄清楚为什么我的views / references /文件夹无法访问。 new.html.erb和index.html.erb都不可用。当我去localhost:3000 /引用我的错误是:

RuntimeError in ReferencesController#index
Circular dependency detected while autoloading constant ReferencesController

I believe this is setup, and It shouldn't be a Rails issue because my other controllers are working fine.

我相信这是设置,它不应该是一个Rails问题,因为我的其他控制器工作正常。

My routes file has resources :references in it, my rake routes produces:

我的路径文件有资源:其中的引用,我的rake路由产生:

references GET    /references(.:format)          references#index
           POST   /references(.:format)          references#create
new_reference GET    /references/new(.:format)      references#new
edit_reference GET    /references/:id/edit(.:format) references#edit
reference GET    /references/:id(.:format)      references#show
           PATCH  /references/:id(.:format)      references#update
           PUT    /references/:id(.:format)      references#update
           DELETE /references/:id(.:format)      references#destroy

So I try to get to my index page by this which should be the correct path.

所以我试着通过这个到达我的索引页面,这应该是正确的路径。

<%= link_to 'References', references_path, class: 'navbar-brand' %>

My model:

我的模特:

class Reference < ActiveRecord::Base
  belongs_to :user
end

My controller:

我的控制器:

class ReferencesControllers < ApplicationController
  def index
    @references = Reference.all
  end

After Google searching, every similar problem seems to be when upgrading from Rails 3 to Rails 4, or updating from OS to mavericks. My other controllers work so I feel it's safe to rule those out. I can't even get to the templates.

在谷歌搜索之后,每个类似的问题似乎都是从Rails 3升级到Rails 4,或从OS更新到mavericks。我的其他控制器工作,所以我觉得把它们排除在外是安全的。我甚至无法访问模板。

2 个解决方案

#1


24  

Rename this ReferencesControllers to ReferencesController

将此ReferencesControllers重命名为ReferencesController

#2


0  

I saw this when refactoring a Rails 4 app. spring stop fixed it.

我在重构Rails 4应用程序时看到了这一点。弹簧停止固定它。

#1


24  

Rename this ReferencesControllers to ReferencesController

将此ReferencesControllers重命名为ReferencesController

#2


0  

I saw this when refactoring a Rails 4 app. spring stop fixed it.

我在重构Rails 4应用程序时看到了这一点。弹簧停止固定它。