如何访问助手中的自定义子目录(Ruby on Rails)?
Ruby on Rails: 有什么方法可以访问 helpers 目录中的子目录吗?
我的意思是:
/app/helpers/"subdir"/"foo.rb"
所以我想访问 foo.rb 中的方法和常量...
Ruby on Rails:
Is there any way to access subdirectories in helpers directory?
I mean:
/app/helpers/"subdir"/"foo.rb"
So I'd like to access methods and constants in foo.rb...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Rails 默认包含所有帮助程序,包括子目录中的帮助程序。
如果您的配置要求控制器包含自己的帮助程序,请将其放入控制器中:
将包含
/app/helpers/subdir/foo_helper.rb
,其方法将可供该控制器的视图使用。Rails includes all helpers by default, including those in subdirectories.
If your configuration requires controllers to include their own helpers, placing this in a controller:
will include
/app/helpers/subdir/foo_helper.rb
, whose methods will be available to that controller's views.