在预生产机器上运行 rails 时出现未定义的方法错误。错误消息如下所示:
undefined method `content_tag' for module `ActionView::Helpers::TagHelper'
(in /home/user/my-rails-app/app/assets/javascripts/templates/general/test.mustache)
错误出现在布局文件中,包含“application.js”的行:
<%= javascript_include_tag "application" %>
堆栈跟踪如下所示:
kernel/delta/module.rb:39:in `alias_method'
haml (4.0.5) lib/haml/helpers/action_view_mods.rb:74:in `__script__'
haml (4.0.5) lib/haml/helpers/action_view_mods.rb:59:in `__script__'
haml (4.0.5) lib/haml/helpers/action_view_mods.rb:38:in `__script__'
haml (4.0.5) lib/haml/helpers/action_view_mods.rb:1:in `__script__'
kernel/common/code_loader.rb:243:in `require'
kernel/common/kernel.rb:705:in `require'
activesupport (4.0.2) lib/active_support/dependencies.rb:229:in `require'
activesupport (4.0.2) lib/active_support/dependencies.rb:214:in `load_dependency'
activesupport (4.0.2) lib/active_support/dependencies.rb:229:in `require'
haml (4.0.5) lib/haml/template.rb:3:in `__script__'
kernel/common/code_loader.rb:243:in `require'
kernel/common/kernel.rb:705:in `require'
activesupport (4.0.2) lib/active_support/dependencies.rb:229:in `require'
activesupport (4.0.2) lib/active_support/dependencies.rb:214:in `load_dependency'
activesupport (4.0.2) lib/active_support/dependencies.rb:229:in `require'
haml (4.0.5) lib/haml/railtie.rb:5:in `__script__'
kernel/common/eval.rb:43:in `instance_eval'
activesupport (4.0.2) lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
activesupport (4.0.2) lib/active_support/lazy_load_hooks.rb:28:in `on_load'
kernel/bootstrap/array.rb:66:in `each'
activesupport (4.0.2) lib/active_support/lazy_load_hooks.rb:27:in `on_load'
haml (4.0.5) lib/haml/railtie.rb:4:in `__script__'
...
我相信这个错误是由于在加载 Haml 时ActionView::Helpers::TagHelper
模块没有定义。content_tag
(相关代码在这里)。由于某种原因,此问题不会出现在其他相同的环境中。任何人都可以为此问题提出修复/解决方法吗?
[更新]
这只发生在开发模式下。我正在使用 rbx-2.2.6、actionpack 版本 4.0.2 和 haml 4.0.5