Steve Harman
Steve Harman

Reputation: 741

Serving a rails 3 app in another rails 3 app using rack

I used rackup in a rails 3 application

rackup config.ru

This started to serve the rails app from port 9292

[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 ). 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.

The examples here are given for Sinatra::Base.

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

Upvotes: 0

Views: 181

Answers (1)

Brandon Jernigan
Brandon Jernigan

Reputation: 461

An idea - I don't have any experience in the matter, so take it for what it is worth :D

You may want to check out 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. Here are some resources:

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

Rails 3.1: Engine vs. Mountable App

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

Upvotes: 0

Related Questions