ActionController::RoutingError: uninitialized constant MicropostsController

8legged picture 8legged · Aug 22, 2013 · Viewed 26.9k times · Source

Update: This was due to a misspelled file name

correct:
~/sample_app/app/controllers/microposts_controller.rb

incorrect:
~/sample_app/app/controllers/microposts_contoller.rb


This is my first contribution here, feedback on improving this or future postings is appreciated :)

Ruby on Rails Tutorial: Learn Web Development with Rails 4

While working through chapter 10.3, I got stuck. In the end, a misspelled file name had me chasing ghosts for a few days.

$ rspec spec/requests/authentication_pages_spec.rb
No DRb server is running. Running in local process instead ...
...FF................

Failures: 

1) Authentication authorization for non-signed-in users in the Microposts controller submitting to the create action 
Failure/Error: before { post microposts_path } 
ActionController::RoutingError: 
uninitialized constant MicropostsController 
# ./spec/requests/authentication_pages_spec.rb:93:in `block (6 levels) in ' 

2) Authentication authorization for non-signed-in users in the Microposts controller submitting to the destroy action 
Failure/Error: before { delete micropost_path(FactoryGirl.create(:micropost)) } 
ActionController::RoutingError: 
uninitialized constant MicropostsController 
# ./spec/requests/authentication_pages_spec.rb:98:in `block (6 levels) in ' 

Finished in 0.92253 seconds 
21 examples, 2 failures 

Failed examples: 

rspec ./spec/requests/authentication_pages_spec.rb:94 # Authentication authorization for non-signed-in users in the Microposts controller submitting to the create action 
rspec ./spec/requests/authentication_pages_spec.rb:99 # Authentication authorization for non-signed-in users in the Microposts controller submitting to the destroy action

Answer

8legged picture 8legged · Aug 28, 2013

This was due to a misspelled file name ~/sample_app/app/controllers/microposts_controller.rb (was microposts_contoller.rb)