Rails:AbstractController :: Helpers :: MissingHelperError – 缺少帮助文件application_helper.rb_helper.rb

找不到任何帮助我的资源! 当我尝试’rails s’并转到应用程序的任何页面时; 它向我发送这个错误页面说我缺少帮助文件。

我认为它在我的台式机上是本地的,因为我最近在笔记本电脑上对应用程序做了一些工作。 我推出笔记本电脑和应用程序在Heroku上工作正常,并在该机器上运行本地零问题。 我添加了一项function,使用Carrierwave,Mini_Magick和Fog将公司徽标图像上传到Amazon S3。

到目前为止我尝试过的事情:我删除了应用程序并将git克隆回到这台机器上。 我已经尝试过Brew卸载/安装imagemagick,并在克隆应用程序后完成了所有基础知识,例如bundle install,rake db:migrate。 仍然没有运气..

这是我在页面上获得的错误代码以及完整的跟踪:

AbstractController::Helpers::MissingHelperError in PagesController#dashboard Missing helper file helpers//users/jamesfend/sites/feedbackz/app/helpers/application_helper.rb_helper.rb Extracted source (around line #1): 1 class ApplicationController < ActionController::Base 2 # Prevent CSRF attacks by raising an exception. 3 # For APIs, you may want to use :null_session instead. 4 protect_from_forgery with: :exception 

完整跟踪

 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 `map!' 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 `' activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `load' 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 `' activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `load' 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 `const_get' 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 `each' activesupport (4.2.0) lib/active_support/inflector/methods.rb:259:in `inject' 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 `each' 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' warden (1.2.3) lib/warden/manager.rb:35:in `block in call' warden (1.2.3) lib/warden/manager.rb:34:in `catch' warden (1.2.3) lib/warden/manager.rb:34: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 `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' actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17: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' 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/jamesfend/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service' /Users/jamesfend/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run' /Users/jamesfend/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread' 

页面控制器

 class PagesController < ApplicationController def dashboard @title = 'Feedbackz by Amazio Labs' @header_title = 'Dashboard' end def billing @title = 'Billing & Plans - Feedbackz by Amazio Labs' @header_title = 'Billing & Plans' @user = User.find(current_user.id) end def contact @title = 'Contact - Feedbackz by Amazio Labs' @header_title = 'Contact Us' end def faq @title = 'FAQ - Feedbackz by Amazio Labs' @header_title = 'Frequently Asked Questions' end def invoices @title = 'Invoices - Feedbackz by Amazio Labs' @header_title = 'Invoices' end def videos @title = 'Videos - Feedbackz by Amazio Labs' @header_title = 'Helpful Videos' end def schedule @title = 'Schedule - Feedbackz by Amazio Labs' @header_title = 'Schedule of Pending Sends' end end 

这对我有用:

 cd ~ mv sites tmpsites mv tmpsites sites 

我也这样做了,但不确定是否需要:

 cd / sudo ln -s Users users 

奇怪的是,我看不到小写users符号链接,但ls /usersls /Users工作。

循序渐进指南:

在OSX上,我已将用户名更改为Psy 。 因此,解决问题是屁股的痛苦。 按照这些步骤帮助我:

  1. 运行irb并在项目文件夹中执行以下命令:

     File.expand_path("./") # => "/Users/psy/code/rails_app" 
  2. 现在退出irb并在shell中运行此命令:

     $ pwd # => /Users/Psy/code/rails_app 
  3. 比较两者并注意具有大小写差异的目录,在这种情况下它是Psy

  4. 将该目录重命名为任何内容,然后将其重命名回原始文件夹( 在必要时使用sudo

     $ sudo mv /Users/Psy /Users/tmp $ sudo mv /Users/tmp /Users/Psy 

虽然Zubin提供的答案在我的个人计算机上为我工作,但我刚刚在工作机器上遇到了同样的问题。 我创建了一个小写的网站:

 mkdir sites 

用大写字母重命名修复它。

 mv sites Sites 

我发现只重命名网站文件夹对我来说就像祖宾指出的那样。 我没有做sudo ln命令。

 mv sites sites1 mv sites1 sites 

简单地移动/重命名文件夹对我来说不起作用。 我必须重命名现有文件夹,创建一个具有相同名称的新文件夹,然后将所有内容复制到它。 然后我删除了旧的重命名文件夹。

对我来说这个问题是因为我在Windows上使用GitBash并从那里运行我的测试。 看起来与bash期望的实际文件夹名称不匹配。 从cmd跑出来并且工作正常。

如果您使用的是Windows和Powershell,则在文件系统中具有特定大小写的目录中运行rails srails server时会出现此问题,但是如果您使用不同的大小写更改为Powershell中的目录。

例如,在我的Windows文件系统上,我的rails站点位于:

C:/Code/Personal-Website

但我在powershell中运行以下命令来启动我的服务器:

C:\Users\XXX XXX> cd C:/code/personal-website

C:\code\personal-website> rails s

Powershell认为启动服务器的位置与服务器的文档根目录在文件系统中的位置之间的这种情况不匹配似乎会导致问题,并确保您的Powershell位置案例与Windows中的目录匹配将阻止它。

我得到了与上面相同的错误,但这不是由于案件问题。 它最终归结于各种因素。 我安装了两个ruby版本管理器-rvm和rbenv-我使用的是旧的gem安装程序。 我不得不卸载rvm( 如何从我的系统中删除RVM(Ruby版本管理器)? )并重新安装rbenv(brew重新安装rbenv)并升级到最新版本的ruby。 然后我不得不更新rubygems(gem update –system)。 然后,重新安装所有gem和重新启动,一切都修复了。

本质上,我的ruby经理指向旧版本的ruby并使用过时版本的gem installer(2.2.0)。 您可以通过升级rubygems来解决问题。

我花了一天半的时间来解决这个问题。 希望这可以节省一些时间和挫折。

我在运行测试时开始收到相同的丢失助手消息,即使我的应用程序在开发模式下运行正常。 这是在我成功运行测试之后开始的,没有我知道的系统更改。 在尝试从我的路径中删除大写文件名但没有成功之后,我运行了rvm,在我的情况下

 rvm use ruby-2.2.0@rails4.2 bundle install 

问题消失了。 我怀疑我的系统已重新启动并开始使用一些不兼容的系统Ruby模块。 我是初学者,通过Michael Hartl的OS X 10.10.3轨道教程。

我也遇到过这个错误。 这里的所有解决方案都没有成功,我尝试了不同的东西。 这是我的解决方案,也可以帮助其他人:

在我的项目路径中有一个带有元音突变的文件夹/“Umlaut”(ü,ö,ä等)。 所以我改变了一切,一切正常。

这不是真正的ruby或Rails错误,因为它是OSX(恕我直言)中的一个缺陷,这是因为多年前设计决定保持与OS 8.0(经典MacOS)的兼容性,并提供与Windows FAT / NTFS更好的兼容性。 该决定是使用保留大小写但不区分大小写的命名方案来实现HFS +,其中以下路径是等效的:

  /tmp/CASE_insensitive /tmp/case_INSENSITIVE 

您可以在以下quorapost中阅读有关此内容的更多信息:

为什么OS X选择使用不区分大小写的文件系统而不是区分大小写的文件系统?

如果你曾经配置过一个HFS +文件系统来强制不区分大小写(你知道,为了与实际的* nix文件系统更兼容),你可能会遇到一个刚刚在OSX上破解的软件,因为该软件已经有些粗心地编写为假设没有不区分大小写(IIRC,一些Adobe软件在HFS +中具有区分大小写的问题)。

在OSX终端中尝试这个:

  prompt>mkdir /tmp/CASE_insensitive prompt>cd /tmp/case_INSENSITIVE prompt>pwd /tmp/case_INSENSITIVE 

恕我直言,这太乱了。 现在,如果您在OSX系统上使用Pow ,当您在~/.pow目录中创建符号链接以指向您的Rails应用程序时,请注意这种情况。 在此处错误输入案例将导致OP注意到错误。 只需使用适当的大小写删除和重命名符号链接,就可以正确地解决这个问题。