在 Rails 中,安装 gem,然后将 gems:freeze 放入供应商文件夹与将其作为插件安装有什么区别?
两种方法都将 gem 放入项目的文件夹中,成为一个独立的项目。这些方法是否有优点/缺点,或者其中一种方法比另一种方法更好?
(该项目是Rails 2.2项目,所以不能使用Bundler)
Both methods put the gem into the project's folder to be a self-contained project. Is there advantage / disadvantage of these methods or one better than the other method?
(the project is a Rails 2.2 project, so can't use Bundler)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
插件最近在 Rails 世界中逐渐过时,我猜是因为它们更难维护,或者因为它们被认为是不太优雅的解决方案。
此外,您可以在 2.2 项目中使用 Bundler(我有使用 2.3 和 2.2 的经验,应该是相同的,对吧?)。您只需要在 config/initializers 文件夹中设置一个初始化程序: http: //docs.heroku.com/bundler#using-bundler-from-rails-23x
Plug ins are falling out of fashion in the Rails world lately because they are harder to maintain, I guess or because they are considered a less elegant solution.
Besides, you can use Bundler in a 2.2 project (I have experience doing it with a 2.3 and 2.2 should be the same, right?). You only need to set up an initializer in your config/initializers folder: http://docs.heroku.com/bundler#using-bundler-from-rails-23x
差异以及插件不再受青睐的原因在于,插件安装一次,并且无法轻松跟踪或更新。另外,您每次都必须从网络重新安装该插件。如果您有一个快速变化的插件,那么下次您在项目中使用它时,它可能会与今天截然不同。
宝石有两大优点:
我希望这有帮助!
The difference, and the reason plugins have fallen out of favor, is that a plugin is installed once, and can't easily be tracked or updated. Plus, you have to re-install that plugin from the web every time. If you have a fast-changing plugin, then the next time you use it in a project it might be drastically different than it is today.
Gems have two big advantages:
I hope this helps!