Ruby on Rails 插件开发流程

发布于 2024-08-10 18:59:54 字数 210 浏览 1 评论 0原文

我正在考虑将网站的各个方面开发为 Rails 插件以供重用。我的问题是关于开发过程。由于每个插件都将提供功能“切片”,我是否应该将每个“切片”开发为自己的应用程序,然后将每个应用程序的代码提取到插件中?或者,我应该将它们作为插件编写在应用程序中吗?最终我将链接到每个站点的这些插件以保持干燥。

我想主要问题是创建多个“引擎”类型插件的开发过程是什么?

预先感谢您的任何帮助。

I'm considering developing aspects of a website as Rails plugins for reuse. My question is about the development process. Since each of these plugins will provide a "slice" of functionality, should I develop each "slice" as it's own application and then extract the code from each application into a plugin? Or, should I write them as plugins right in an application? Ultimately I will be linking to these plugins from each site to keep it DRY.

I guess the main question is what would be the development process for creating multiple "Engine" type plugins?

Thanks in advance for any help.

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

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

发布评论

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

评论(2

泛滥成性 2024-08-17 18:59:54

任何一种方法都是有效的。

在编写基本插件时,我通常发现将其与使用它的应用程序一起编写会更容易。因为我发现围绕已经存在的东西进行设计/测试更容易。

然而,当谈到引擎插件时,我更喜欢将它们开发为单独的应用程序,然后在将其移动到插件中时删除所有不必要的部分。它们本质上是迷你应用程序,当安装在新创建的 Rails 项目上时,它们应该具有完整的功能。

通过将它们设计为自己的应用程序,我可以确保适当的划分。这确保了我不会意外地引用不属于我正在开发的引擎的一部分的代码模型/控制器/视图/帮助器。

如果您以这种方式开发多个引擎类型插件,您可能需要使用实用程序脚本来压缩一些步骤。例如,简化将应用程序转变为引擎插件的过程。

它应该根据需要重组您的应用程序并填充插件应具有的文件,例如 init.rb。

Either approach is valid.

When writing a basic plugin I usually find it easier to write it in tandem with the application that will use it. Because I find it easier to design/test around something that already exists.

However, when it comes to Engine plugins, I prefer to develop them as a separate application and then rip out all the unnecessary bits when I move it into a plugin. They are in essence mini applications, and they should be completely functional when installed on a freshly created rails project.

By designing them as their own application I'm ensuring proper compartmentalization. This ensures that I'm not accidentally referring to code models/controllers/views/helpers that are not a part of the engine I'm developing.

If you're developing multiple engine type plugins this way, you might want to condense a few of the steps with a utility script. Such as one that streamlines the process of turning an application into an Engine plugin.

It should restructure your app as necessary and populate the files that plugins should have, such as init.rb.

酷到爆炸 2024-08-17 18:59:54

您可能还想看看 Desert 框架。

You might want to give a look to Desert framework as well .

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