【问题标题】:link_to not working in a helper module (rails)link_to 在辅助模块(rails)中不起作用
【发布时间】:2011-05-27 18:37:51
【问题描述】:

所以我试图在帮助模块中调用 link_to

这里是代码

 module GroupsHelper

    include ActionView::Helpers::TextHelper
    include ActionView::Helpers::UrlHelper


   def self.link_to_publish
        link_to "test"  
    end


 end

返回

 undefined local variable or method `link_to' for GroupsHelper:Module

有人知道为什么吗?谢谢

【问题讨论】:

标签: ruby-on-rails


【解决方案1】:

删除“自我”。这不是类方法。

假设:GroupsHelper 在 rails 应用的 app/helpers/groups_helper.rb 中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-11
    • 2013-12-22
    • 2016-06-01
    • 1970-01-01
    • 2013-12-06
    相关资源
    最近更新 更多