提问人: 提问时间:7/22/2016 更新时间:9/12/2016 访问量:705
如何在我的 Rails 模块中定义一个辅助方法?
How do I define a helper method in my Rails module?
问:
我正在使用 Rails 4.2.4。如何在模块中定义帮助程序(私有)方法?我有这个模块
module WebpageHelper
def get_url(url)
content = get_content(url)
..
end
def get_content(url)
…
end
module_function :get_url
end
我不希望“get_content”方法可以公开访问,但是使用上面的代码时,我得到了错误
Error during processing: undefined method `get_content' for WebpageHelper:Module
如何在我的模块中正确定义私有帮助程序方法?
答:
评论