【问题标题】:Why does Rails 4 say Missing Helper file, though it is there?为什么 Rails 4 说 Missing Helper 文件,虽然它在那里?
【发布时间】:2013-09-23 18:38:06
【问题描述】:

我在 Rails 3 中写了一个项目。有三个控制器,三个视图,三个帮助文件(非常小的项目)。

其中一个帮助文件,可能是导致问题的原因:

> cat helpers/my_helper.rb

module MyHelper

    require 'some_gems'
    ...

    def my_function ()
       ... #some functionality
    end

end

现在我搬到了 Rails 4(更新了所有员工)。

当刚刚启动应用程序rails s -b localhost -p 3000 并在浏览器中转到localhost:3000 时,我得到一个异常:

AbstractController::Helpers::ClassMethods::MissingHelperError in WelcomeController#index
Missing helper file helpers/my_helper.rb

有什么问题?文件就在那里,为什么 Rails 还是找不到它?

【问题讨论】:

  • 问题出在 Gemfile :)

标签: ruby-on-rails ruby exception ruby-on-rails-4 missing-data


【解决方案1】:

这可能是由于缺少它试图要求库的 gem 而无法加载帮助程序。请检查您的Gemfile 是否包含此助手所需的所有宝石。

【讨论】:

  • 太棒了!但它并不是很明显。
猜你喜欢
  • 1970-01-01
  • 2015-11-28
  • 1970-01-01
  • 1970-01-01
  • 2022-01-08
  • 2017-09-13
  • 2011-01-22
  • 1970-01-01
  • 2012-04-25
相关资源
最近更新 更多