简体   繁体   English

使用机架在另一个Rails 3应用程序中提供Rails 3应用程序

[英]Serving a rails 3 app in another rails 3 app using rack

I used rackup in a rails 3 application 我在Rails 3应用程序中使用了stackup

rackup config.ru 机架配置

This started to serve the rails app from port 9292 这开始从端口9292开始服务Rails应用程序

[2012-08-01 23:00:05] INFO  WEBrick 1.3.1
[2012-08-01 23:00:05] INFO  ruby 1.9.3 (2011-10-30) [x86_64-darwin11.2.0]
[2012-08-01 23:00:05] INFO  WEBrick::HTTPServer#start: pid=3887 port=9292

Now, I want to use this Rails 3 app (A) from inside another rails 3 app (B) under a path (say /mycoolappB ). 现在,我想从路径下的另一个Rails 3应用程序(B)内部使用此Rails 3应用程序(A)(例如/ mycoolappB)。 According to what I learn, I need to modify the routes.rb in app B by adding a match command that can direct this path to App A. 根据我的了解,我需要通过添加可将此路径定向到应用程序A的匹配命令来修改应用程序B中的route.rb。

The examples here are given for Sinatra::Base. 这里给出了Sinatra :: Base的示例。

http://asciicasts.com/episodes/222-rack-in-rails-3 http://asciicasts.com/episodes/222-rack-in-rails-3

So, I was wondering if what I am trying to do here is possible and, if so, what would be the best approach. 因此,我想知道我在这里尝试做的事情是否可能,如果可以,最好的方法是什么。

thanks in advance, 提前致谢,

Steve 史蒂夫

An idea - I don't have any experience in the matter, so take it for what it is worth :D 一个想法-我在这方面没有任何经验,所以以它值得的方式来考虑:D

You may want to check out Rails Engines. 您可能需要查看Rails Engines。 I believe this will be the best approach for you from what you described. 我相信这将是您所描述的最佳方法。 The idea is to mount app_b inside app_a so that app_a can use all of the controllers, models and routes. 想法是将app_b挂载在app_a内,以便app_a可以使用所有控制器,模型和路由。 Here are some resources: 以下是一些资源:

http://edgeguides.rubyonrails.org/engines.html http://edgeguides.rubyonrails.org/engines.html

Rails 3.1: Engine vs. Mountable App Rails 3.1:引擎与可安装的应用程序

http://www.astjohn.ca/2011/08/06/rails-31-engines-mountable-or-full-part-1 http://www.astjohn.ca/2011/08/06/rails-31-engines-mountable-or-full-part-1

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

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