【问题标题】:access helper file method in more than one view?在多个视图中访问帮助文件方法?
【发布时间】:2015-11-26 10:57:00
【问题描述】:

在我的ApplicationHelper.rb

def price_count
   my code is here
end

我想在多个视图文件中访问它。

谢谢。

【问题讨论】:

  • 您尝试访问了吗?
  • @nithin 是的,我试过了
  • 在其他视图文件中访问时出现什么错误?
  • 得到这个错误 => 未定义的局部变量或方法 `price_count'

标签: ruby-on-rails ruby helper


【解决方案1】:

我猜你已经设置了这个

config.action_controller.include_all_helpers = false

在 /config/application.rb 中

false 更改为true,您将能够在所有视图中访问您的辅助方法。

【讨论】:

    猜你喜欢
    • 2018-07-10
    • 2015-05-06
    • 2011-09-08
    • 1970-01-01
    • 1970-01-01
    • 2017-07-15
    • 2012-08-26
    • 1970-01-01
    • 2011-07-07
    相关资源
    最近更新 更多