轨道 6 + Zeitwerk,加载没有类的文件
我们正在升级到 Rails 6,并且已经完成了使我们的应用程序能够与 Zeitwerk 配合使用的大部分工作。
我们确实有两个文件,它们是查询对象,存在于 app/queries
下,并且我们没有为它们定义类。它们仅与方法一起存在。
然而,Zeitwerk 希望该文件定义一个常量,但我们认为没有必要。
有什么方法可以告诉 Zeitwerk 我们要按原样加载这些文件吗?
We are upgrading to Rails 6, and have done most of the work to make our application work with Zeitwerk.
We do have two files, which are query objects, existing under app/queries
and we don't define a class for them. They exists with methods only.
However, Zeitwerk expects the file to define a constant, but we don't deem it necessary.
Is there any way to tell Zeitwerk that we want to load these files as is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以告诉主自动加载器忽略它们:
然后应用程序负责使用
require
或其他方式加载它们。如果应忽略
app/queries
下的所有内容,您可以忽略目录本身:You can tell the main autoloader to ignore them:
And then the application is responsible for loading them using
require
or whatever.If everything under
app/queries
should be ignored, you can ignore the directory itself: