如何访问助手中的自定义子目录(Ruby on Rails)?

发布于 2025-01-01 06:41:11 字数 137 浏览 4 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

路还长,别太狂 2025-01-08 06:41:11

Rails 默认包含所有帮助程序,包括子目录中的帮助程序。

如果您的配置要求控制器包含自己的帮助程序,请将其放入控制器中:

helper "subdir/foo"

将包含 /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:

helper "subdir/foo"

will include /app/helpers/subdir/foo_helper.rb, whose methods will be available to that controller's views.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文