gpt4 book ai didi

ruby-on-rails - Ruby on Rails中的Gem Vs插件Vs引擎

转载 作者:行者123 更新时间:2023-12-03 10:14:29 24 4
gpt4 key购买 nike

Ruby on Rails中的Gem包,插件和Engine有什么区别?

我认为我们在Rails3.2之前使用插件,而在rails3.2发布之后我们使用gem包作为插件,但是如何在ROR中使用引擎?

最佳答案

您从Rails 2中了解到的插件(即vendor/plugins文件夹下的插件)已弃用于Rails 3.2;在Rails 4中已完全删除了对它的支持。现在,有了"gemified plugin"的概念,其中插件本质上是作为gems构建的,并且可以在不同的Rails应用程序之间共享。

但是要回答有关gems和plugins的问题,请查看此Stackoverflow answer。长话短说,来自Rails 2的plugins是rails应用程序的扩展,而gem是打包的 ruby 应用程序。

至于Rails引擎,我发现这是Rails引擎的a pretty easy and intuitive definition:

Rails Engines is basically a whole Rails app that lives in the container of another one. Put another way, as the docs note: an app itself is basically just an engine at the root level. Over the years, we’ve seen sen engines as parts of gems such as devise or rails_admin. These example show the power of engines by providing a large set of relatively self-contained functionality “mounted” into an app.



而且,由于rails引擎和插件都是ruby应用程序的类型,因此从技术上讲,它们都可以打包并用作 gem (通常)。

关于ruby-on-rails - Ruby on Rails中的Gem Vs插件Vs引擎,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23118472/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com