[英]rails use helper in partial
I have a shared partial in 我有一个共享部分
-shared
└──-foo
└──-bar
└──baz.html.erb
And in it I'm trying to access a helper method in 在其中,我正在尝试访问辅助方法
-helpers
└──foo_helper.rb
But I am getting un undefined method
error. 但我得到undefined method
错误。
How can I include that helper method in my partial in an elegant way? 如何以优雅的方式在我的部分中包含辅助方法?
Put 放
helper :foo
in your application controller. 在你的应用程序控制器 This should make the helpers in foo_helper available across all actions. 这应该使foo_helper中的帮助程序可用于所有操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.