1

I've got an ordinary rails app which now gets some widgets which are rendered inside a Sinatra app.

On my local machine I run rails s and ruby lib/sinatra/widget.rb which then fetches stuff from the rails app. As a result localhost:3000 and localhost:4567 work fine together.

How can I do all this in a staging environment? The deployment itself is working and the rails app starts up. How can I access the Sinatra stuff now?

One idea would be mounting the Sinatra app to some path in the rails app? Any ideas, suggestions?

Cojones
  • 2,930
  • 4
  • 29
  • 41

1 Answers1

2

Here is an article from Thoughtbot, which shows two approaches on how to use Sinatra application inside your Rails app.

The simpler method is to use Rails router:

require 'my_sinatra_app'

MyRailsApp::Application.routes.draw do
  mount MySinatraApp.new => '/sinatra'
end

It's a preferable approach unless you need a custom middleware for each app.

dimakura
  • 7,575
  • 17
  • 36