了解 Rails 助手

发布于 2024-11-17 03:13:58 字数 216 浏览 5 评论 0原文

我有两个帮助文件。 events_helper.rb 和 users_helper.rb。

这两个帮助程序文件都有一个名为 foobar 的方法。在事件控制器中,索引视图。如果我调用 foobar.难道它不应该加载 events_helper.rb 中的帮助器 foobar 吗?

或者这不是助手的工作方式?

I have two helper files. events_helper.rb and users_helper.rb.

Both of these helper files have a method called foobar. In events controller, index view. If I call foobar. Shouldn't it load the helper foobar thats in events_helper.rb?

Or is this not the way helpers work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

山川志 2024-11-24 03:13:58

似乎所有助手都可用 - 所以不确定在您的情况下会选择哪一个,最好是事件控制器……从您的评论来看,它似乎选择了错误的一个。

你能给他们起不同的名字吗?

为什么所有 Rails 助手始终可供所有视图使用?有办法禁用它吗?

Seems like all helpers are available - so not sure which it would choose in your case, ideally the events controller one... and from your comment, it seems like its chosen the wrong one.

Could you give them distinct names?

Why are all Rails helpers available to all views, all the time? Is there a way to disable this?

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