Rails 4 Runtime error in controller: Circular dependency detected while autoloading constant

user3138341 picture user3138341 · Mar 12, 2014 · Viewed 17.7k times · Source

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.

Answer

Vasu Adari picture Vasu Adari · Mar 12, 2014

Rename this ReferencesControllers to ReferencesController