Rails 3 中的插件与引擎,作为 gem 提供

发布于 2024-09-26 02:58:31 字数 266 浏览 0 评论 0原文

在 Rails::Plugin(针对 Rails 3)的文档中,我正在阅读以下内容:

“...您实际上不能在插件中声明 Rails::Engine,否则会导致相同的文件被加载两次。这意味着如果你想将引擎作为 gem 发布,它就不能用作插件,反之亦然。”

谁能更具体地说明哪些文件被加载两次?我已经声明了一个插件/gem 作为引擎,并且它也可以很好地放入供应商/插件中(并且我想保持这种方式),尽管有上面的声明。我只是想弄清楚为什么(以及是否)这不是一件好事。

谢谢你!

In the documentation for Rails::Plugin (for Rails 3), I'm reading the following:

"... you actually cannot declare a Rails::Engine inside your Plugin, otherwise it would cause the same files to be loaded twice. This means that if you want to ship an Engine as gem it cannot be used as plugin and vice-versa."

Can anyone be more specific about exactly what files get loaded twice? I have declared a plugin/gem as Engine, and it works fine also being put inside vendor/plugins (and I'd like to keep it this way), in spite of the statement above. I simply want some clarity on why (and whether) this is not a good thing to do.

Thank you!

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

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

发布评论

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

评论(1

一页 2024-10-03 02:58:31

我自己没有确切的答案,但这个主题包含在我发现有用的资源中:

https:// /gist.github.com/e139fa787aa882c0aa9c

I don't have an exact answer myself, but this subject is covered in this resource which I have found helpful:

https://gist.github.com/e139fa787aa882c0aa9c

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