Rails 3 中的插件与引擎,作为 gem 提供
在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己没有确切的答案,但这个主题包含在我发现有用的资源中:
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