Rails 中的奇怪错误 - 缺少助手

2024-04-16

我不确定,但这可能与崩溃的计算机有关。重新启动后(崩溃后),我收到丢失助手错误,其中助手名称错误。切换分支对结果没有影响。

错误是:

缺少帮助程序文件 helpers//users/xxxx/sites/xxxx/app/helpers/accounts_helper.rb_helper.rb

我尝试过更新 gems、卸载 Rails 并重新安装、检查助手名称以及包含助手的任何位置。我还查看了 git 日志并检查了最近更改的代码。没有运气。

堆栈跟踪

Started GET "/" for 127.0.0.1 at 2015-01-09 17:53:57 -0700
  ActiveRecord::SchemaMigration Load (1.1ms)  SELECT "schema_migrations".* FROM "schema_migrations"

AbstractController::Helpers::MissingHelperError - Missing helper file helpers//users/xxxx/sites/xxxx/app/helpers/accounts_helper.rb_helper.rb:
  actionpack (4.2.0) lib/abstract_controller/helpers.rb:151:in `rescue in block in modules_for_helpers'
  actionpack (4.2.0) lib/abstract_controller/helpers.rb:148:in `block in modules_for_helpers'
  actionpack (4.2.0) lib/abstract_controller/helpers.rb:144:in `modules_for_helpers'
  actionpack (4.2.0) lib/action_controller/metal/helpers.rb:93:in `modules_for_helpers'
  actionpack (4.2.0) lib/abstract_controller/helpers.rb:108:in `helper'
  actionpack (4.2.0) lib/action_controller/railties/helpers.rb:17:in `inherited'
  app/controllers/application_controller.rb:1:in `<top (required)>'
  activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `block in load_file'
  activesupport (4.2.0) lib/active_support/dependencies.rb:647:in `new_constants_in'
  activesupport (4.2.0) lib/active_support/dependencies.rb:456:in `load_file'
  activesupport (4.2.0) lib/active_support/dependencies.rb:354:in `require_or_load'
  activesupport (4.2.0) lib/active_support/dependencies.rb:494:in `load_missing_constant'
  activesupport (4.2.0) lib/active_support/dependencies.rb:184:in `const_missing'
  app/controllers/pages_controller.rb:1:in `<top (required)>'
  activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `block in load_file'
  activesupport (4.2.0) lib/active_support/dependencies.rb:647:in `new_constants_in'
  activesupport (4.2.0) lib/active_support/dependencies.rb:456:in `load_file'
  activesupport (4.2.0) lib/active_support/dependencies.rb:354:in `require_or_load'
  activesupport (4.2.0) lib/active_support/dependencies.rb:494:in `load_missing_constant'
  activesupport (4.2.0) lib/active_support/dependencies.rb:184:in `const_missing'
  activesupport (4.2.0) lib/active_support/inflector/methods.rb:261:in `block in constantize'
  activesupport (4.2.0) lib/active_support/inflector/methods.rb:259:in `constantize'
  activesupport (4.2.0) lib/active_support/dependencies.rb:566:in `get'
  activesupport (4.2.0) lib/active_support/dependencies.rb:597:in `constantize'
  actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:69:in `controller_reference'
  actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:59:in `controller'
  actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:38:in `serve'
  actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
  bullet (4.14.0) lib/bullet/rack.rb:10:in `call'
  meta_request (0.3.4) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
  meta_request (0.3.4) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
  rack (1.6.0) lib/rack/etag.rb:24:in `call'
  rack (1.6.0) lib/rack/conditionalget.rb:25:in `call'
  rack (1.6.0) lib/rack/head.rb:13:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
  rack (1.6.0) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.6.0) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
  activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
  activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
  activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  better_errors (2.1.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.0) lib/better_errors/middleware.rb:57:in `call'
  rack-contrib (1.2.0) lib/rack/contrib/response_headers.rb:17:in `call'
  meta_request (0.3.4) lib/meta_request/middlewares/headers.rb:16:in `call'
  web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:18:in `middleware_call'
  web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:13:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.0) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.0) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
  rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
  rack-mini-profiler (0.9.2) lib/mini_profiler/profiler.rb:300:in `call'
  railties (4.2.0) lib/rails/engine.rb:518:in `call'
  railties (4.2.0) lib/rails/application.rb:164:in `call'
  rack (1.6.0) lib/rack/lock.rb:17:in `call'
  rack (1.6.0) lib/rack/content_length.rb:15:in `call'
  rack (1.6.0) lib/rack/handler/webrick.rb:89:in `service'
  /Users/Hank/.rvm/rubies/ruby-2.2.0-rc1/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
  /Users/Hank/.rvm/rubies/ruby-2.2.0-rc1/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
  /Users/Hank/.rvm/rubies/ruby-2.2.0-rc1/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'

该问题似乎是在最新版本的 ruby​​,ruby 2.2.0 中引入的。

尝试这个实验:

在 Rails 控制台/或 irb 中:

[1] pry(main)>File.expand_path ("./") 
=> "/users/xxxx/Sites/xxxx"

并在终端窗口中:

]$ pwd
/users/xxxx/sites/xxxx

看到不同的情况了吗?如果你明白了这一点,那么在积极支持的深处,正则表达式就会出问题。一种修复方法是删除“sites”目录并重新创建。使用查找器重命名站点目录也可能有效,例如将其重命名为“foobar”,然后返回“sites”。

hth.

(摘自日本本页)

当我与另一个人调试这个问题时,路径中包含大小写混合的目录名就足够了。我们将其重命名为“farknerd”,然后恢复原来的状态(除了全部小写),并且它起作用了。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Rails 中的奇怪错误 - 缺少助手 的相关文章

随机推荐