问题
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:
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.
My routes file has resources :references
in it, my rake routes produces:
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.
回答1:
Rename this ReferencesControllers
to ReferencesController
回答2:
I saw this when refactoring a Rails 4 app. spring stop
fixed it.
来源:https://stackoverflow.com/questions/22359603/rails-4-runtime-error-in-controller-circular-dependency-detected-while-autoload