作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
更新 : 这是因为文件名拼写错误
正确的:~/sample_app/app/controllers/microposts_controller.rb
不正确:~/sample_app/app/controllers/microposts_contoller.rb
这是我在这里的第一个贡献,感谢有关改进此帖子或 future 帖子的反馈:)
Ruby on Rails 教程:Learn Web Development with Rails 4
在完成章节 10.3 的同时, 我被困。最后,一个拼错的文件名让我追了几天鬼。
$ 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
最佳答案
这是由于拼写错误的文件名 ~/sample_app/app/controllers/microposts_controller.rb (是 microposts_contoller.rb)
关于ruby-on-rails - ActionController::RoutingError: 未初始化的常量 MicropostsController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18391048/
更新 : 这是因为文件名拼写错误 正确的:~/sample_app/app/controllers/microposts_controller.rb 不正确:~/sample_app/app/cont
我是一名优秀的程序员,十分优秀!