尝试在railstutorial.org上执行Rails教程。我目前正处于本教程的测试部分,并且在执行测试时仍然遇到错误。我使用'生成的测试文件生成StaticPages控制器'命令是按原样,我根本没有修改它。当我输入命令' rails test'我收到这个错误:
/Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/helpers.rb:152:in在modules_for_helpers中拦截救援':失踪帮手文件助手// users / user / programming / odin / rails / sample_app / app / helpers / application_helper.rb_helper.rb(AbstractController :: Helpers :: MissingHelperError)
以下是追溯:
来自/Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/helpers.rb:149:in
block in modules_for_helpers' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/helpers.rb:145:in
地图!' 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/helpers.rb:145:inmodules_for_helpers' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/action_controller/metal/helpers.rb:93:in
modules_for_helpers' 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/helpers.rb:109:inhelper' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/action_controller/railties/helpers.rb:17:in
继承了&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.1/lib/action_view/test_case.rb:11:in<class:TestCase>' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.1/lib/action_view/test_case.rb:10:in
&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.1/lib/action_view/test_case.rb:8:in<top (required)>' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in
要求&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:inblock in require' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in
load_dependency&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:inrequire' from /Users/user/.rvm/gems/ruby-2.3.0/gems/rails-controller-testing-0.1.1/lib/rails-controller-testing.rb:16:in
阻止&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:38:ininstance_eval' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:38:in
execute_hook&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:45:inblock in run_load_hooks' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:44:in
每个&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:44:inrun_load_hooks' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.1/lib/action_view/base.rb:215:in
&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.1/lib/action_view/base.rb:139:in<module:ActionView>' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.1/lib/action_view/base.rb:10:in
&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:inrequire' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in
阻止在需要&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:inload_dependency' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in
要求&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/debug_exceptions.rb:5:in<top (required)>' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in
要求&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:inblock in require' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in
load_dependency&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:inrequire' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application/default_middleware_stack.rb:48:in
阻止build_stack&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application/default_middleware_stack.rb:13:intap' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application/default_middleware_stack.rb:13:in
build_stack&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application.rb:504:indefault_middleware_stack' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/engine.rb:506:in
阻止应用程序&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/engine.rb:504:insynchronize' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/engine.rb:504:in
app&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application/finisher.rb:37:inblock in <module:Finisher>' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in
instance_exec&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:inrun' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:55:in
阻止run_initializers&#39; 来自/Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:228:inblock in tsort_each' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:350:in
块(2级)in each_strongly_connected_component&#39; 来自/Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:431:ineach_strongly_connected_component_from' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:349:in
块中的each_strongly_connected_component&#39; 来自/Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:ineach' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in
来电&#39; 来自/Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:ineach_strongly_connected_component' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:226:in
tsort_each&#39; 来自/Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:205:intsort_each' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:54:in
run_initializers&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application.rb:352:ininitialize!' from /Users/user/Programming/Odin/rails/sample_app/config/environment.rb:5:in
&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:92:inrequire' from /Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:92:in
preload&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:143:inserve' from /Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:131:in
阻止运行&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:inloop' from /Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in
运行&#39; 来自/Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in<top (required)>' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in
要求&#39; 来自/Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire' from -e:1:in
&#39;
如果格式化并且问得不好或者我不道歉,那么任何帮助都会非常感激我绝对难过。 这是github回购:https://github.com/JDjedi/sample_app
Rails版本为5.0,ruby版本为2.3.0p0
答案 0 :(得分:0)
application_helper.rb_helper.rb
- 这就是你打电话给你帮手的方式吗? .rb
是一个扩展名。因此,您可以将帮助文件的名称更改为application_helper.rb
并查看是否有效吗?
编辑:
这似乎是一个有效的答案:https://stackoverflow.com/a/28269245/1010826
只需将根文件夹重命名为相同名称即可。不知道为什么会起作用,但是:)