简体   繁体   English

如何将现有的Rails应用程序转换为gem

[英]How to convert existing rails application to gem

I have a rails application that is kind of similar to the active_admin gem. 我有一个类似于active_admin gem的Rails应用程序。 I want to make this existing application into a gem. 我想将此现有应用程序变成一个宝石。

I know that you can generate a gem with: 我知道您可以使用以下方法生成宝石:

bundler gem gem_name_here

This command creates an empty gem. 此命令创建一个空的宝石。 Which is fine I suppose, I just don't know where to put all my code. 我想那很好,我只是不知道将所有代码放在哪里。

You're ostensibly supposed to put all of your code in the /lib directory. 表面上,您应该将所有代码放在/lib目录中。 However, my application has an assets pipeline and an app directory with all my models, controllers, and views. 但是,我的应用程序有一个资产管道和一个包含所有模型,控制器和视图的app目录。 I don't know where to place all of these directories in the gem. 我不知道将所有这些目录放置在gem中的位置。 Any thoughts or ideas? 有什么想法或想法吗?

If you need me to share any code, I'll gladly share it. 如果您需要我分享任何代码,我将很乐意分享。

You're describing a rails engine. 您正在描述一个Rails引擎。 Engine is a miniature rails application that can be used inside other rails app. Engine是一个微型Rails应用程序,可以在其他rails应用程序内使用。 For more details see official rails guide 有关更多详细信息,请参见官方rails指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM