Is there a way to create rails app within gem?

I'm trying to make my gem work as an application: when I run rails server inside gem's directory I'd like to see it working just like regular application. But still able to include this gem via Gemfile of any other rails app.

Is it even possible?


Look into rails engines. With full engines you can package apps in a way that they can be pulled into other apps. See refineryCMS for an example of this.

Here is an article on creating an api that can be mounted within another app: https://netguru.co/blog/rails-api-as-an-engine

With a full engine the parent app will inherit the routes defined by the engine. With a mountable engine they are namespaced by default. If you want the app to behave as a standalone app you can do something like:

mount MyEngine::Engine => "/
链接地址: http://www.djcxy.com/p/81136.html

上一篇: 部署后无效真伪令牌

下一篇: 有没有办法在gem内创建rails应用程序?