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

Rails: AbstractController::Helpers::MissingHelperError - Missing helper file application_helper.rb_helper.rb

找不到任何对我有帮助的资源!当我尝试 'rails s' 并转到应用程序的任何页面时;它向我显示了这个错误页面,说我缺少帮助文件。

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

到目前为止我已经尝试过的事情:我已经删除了应用程序并将其git 克隆回这台机器。我已经尝试了 Brew uninstall/install imagemagick 并完成了所有基础操作,例如捆绑安装,克隆应用程序后 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 `<top (required)>'
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 `<top (required)>'
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 都有效。

我发现仅重命名站点文件夹对我有用,就像 Zubin 指出的那样。我没有执行 sudo ln 命令。

mv sites sites1
mv sites1 sites

虽然 Zubin 提供的答案在我的个人机器上对我有用,但我只是 运行 在工作机器上遇到了同样的问题,但它并不完全正确。我将网站创建为小写目录:

mkdir sites 

用大写重命名 s 修复了它。

mv sites Sites

分步指南:

在 OSX,我将我的用户名从 psy 更改为 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
    

我遇到了和上面一样的错误,但不是因为大小写问题。它最终是由于多种因素的结合。我安装了两个 ruby 版本管理器——rvm 和 rbenv——我使用的是旧的 gem 安装程序。我不得不卸载 rvm (How can I remove RVM (Ruby Version Manager) from my system?) 并重新安装 rbenv (brew reinstall rbenv) 并升级到最新版本 ruby。然后我不得不更新 rubygems (gem update --system)。然后,重新安装所有 gem 并重新启动,一切都已修复。

基本上,我的 ruby 经理指向旧版本的 ruby 并使用过时版本的 gem 安装程序 (2.2.0)。您可能只需升级到 rubygems 即可解决问题。

我花了一天半的时间才解决这个问题。希望这会节省一些时间和挫败感。

我在 运行ning 测试时开始收到相同的缺少帮助消息,即使我的应用 运行 在开发模式下正常。这在我成功完成 运行 测试后就开始了,没有我知道的系统更改。在尝试了从我的路径中删除大写文件名的建议但没有成功之后,我 运行 rvm,在我的例子中

rvm use ruby-2.2.0@rails4.2
bundle install

问题消失了。我怀疑我的系统已经重新启动并开始使用一些不兼容的系统 Ruby 模块。我是一名初学者,正在学习 Michael Hartl 关于 OS X 10.10.3.

的 rails 教程

只是 moving/renaming 该文件夹对我不起作用。我不得不重命名现有文件夹,创建一个同名的新文件夹,然后将所有内容复制到其中。然后我删除了旧的重命名文件夹。

我也遇到了这个错误。这里的所有解决方案都没有奏效,我尝试了不同的方法。这是我的解决方案,也可能对其他人有帮助:

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

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

 /tmp/CASE_insensitive
 /tmp/case_INSENSITIVE

您可以在以下 quora post:

中阅读更多相关信息

Why does OS X choose to have a case-insensitive file system instead of a case-sensitive one?

如果您曾经将 HFS+ 文件系统配置为强制不区分大小写(您知道,以便与实际的 *nix 文件系统更加兼容),您很可能会遇到在 OSX 上崩溃的软件,因为该软件编写时有些粗心,假设不区分大小写(IIRC,某些 Adob​​e 软件在区分大小写的 HFS+ 方面遇到了很大的麻烦)。

在 OSX 终端试试这个:

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

恕我直言,这真是一团糟。现在,如果您在 OSX 系统上使用 Pow,当您在 ~/.pow 目录中创建指向您的 Rails 应用程序的符号链接时,请注意案件。在此处输入错误的大小写将导致 OP 指出的错误。只需使用适当的大小写删除符号链接并重命名即可正确解决此问题。

对我来说,这个问题是因为我在 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 位置大小写与 [=29 中的目录匹配=] 将停止它。

我在控制台中用 "spring stop" 解决了。

我在 运行 rails s 上 windows powershell 时收到此错误,但在 cmd 上没有。 我建议使用不同的 CLI。

我从

那里得到了这个错误

rails g controller Name

我刚刚用

删除了控制器

rails d controller Name

然后用小写重新生成

rails g controller name