rails 中的奇怪错误 - 缺少帮助程序 [英] Strange error in rails - missing helper

查看:21
本文介绍了rails 中的奇怪错误 - 缺少帮助程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定,但这可能与崩溃的计算机有关.重新启动后(崩溃后),我收到一个缺少帮助程序错误,其中帮助程序名称错误.切换分支对结果没有影响.

I am not sure , but this might be associated with a crashed computer. After restarting (after the crash) I get a missing helper error where the helper name is wrong. Switching branches has no effect on the outcome.

错误是:

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

Missing helper file helpers//users/xxxx/sites/xxxx/app/helpers/accounts_helper.rb_helper.rb

我尝试过更新 gems、卸载 rails 并重新安装、检查帮助程序名称以及任何包含帮助程序的地方.我还查看了 git 日志并检查了最近更改的代码.没有运气.

Ive tried updating gems, uninstalled rails and reinstalled, checked helper names and anywhere helpers are included. Ive also reviewed git logs and checked recently changed code. No luck.

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中已经引入了.

The problem seems to have been introduced in the latest version of ruby, ruby 2.2.0.

试试这个实验:

在 rails 控制台/或 irb 中:

in rails console/or irb:

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

并在终端窗口中:

]$ pwd
/users/xxxx/sites/xxxx

看到不同的情况了吗?如果你明白了,那么在积极支持的深处,正则表达式会向南.一种解决方法是删除站点"目录并重新创建.使用查找器重命名站点目录也可能起作用,将其重命名为foobar",然后再重命名为sites".

See the different case? If you get that, then deep in the bowels of active support a regex goes south. One fix is to remove the "sites" directory and recreate. It might also work to rename the sites directory using the finder, as rename it to "foobar" and then back to "sites".

(来自日本的这个页面)http://translate.google.com/translate?hl=en&sl=ja&u=http://d.hatena.ne.jp/jiikko/20150108&prev=search

(from this page in Japan) http://translate.google.com/translate?hl=en&sl=ja&u=http://d.hatena.ne.jp/jiikko/20150108&prev=search

当我和另一个人调试这个时,在路径中有一个大小写混合的目录名称就足够了.我们将其重命名为farknerd",然后恢复原样,除了所有小写字母外,它都有效.

And when I was debugging this with another person, it was enough to have a mixed case directory name in the path. We renamed it to 'farknerd' and then back the original, except all lower case, and it worked.

这篇关于rails 中的奇怪错误 - 缺少帮助程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆