Mounting Sinatra app on rails 5

2019-07-31 09:49发布

问题:

I searched the web and don't know why i am getting this errors...

Im trying to mount a Sinatra app that i have to refactor into a rails app so i can do the transition smoothly, so i created a dummy project to test.

My routes file:

Rails.application.routes.draw do   
  match "/sinatra" => SinatraApp, :anchor => false 
end

Sinatra app:

class SinatraApp < Sinatra::Base
  get "/" do
    "Hello Sinatra World"
  end
end

The Sinatra app is located on the lib directory and it is auto loading correctly, i tried to add the Sinatra gem in the gemfile and i got a

"`require': cannot load such file -- rack/showexceptions (LoadError)"

if i not add the gem on the gemfile, or use "require:nil" that error goes away and i got another one

"/active_support/dependencies.rb:293:in `require': cannot load such file -- rack/showexceptions (LoadError)"

If i require 'sinatra' on the Sinatra app, it crashes again with another load error....

I need to have the Sinatra app running inside the rails app so i can navigate thought the Sinatra app like it was running without rails so i can test functionalities and migrate them to the rails app.

回答1:

I was able to resolve this with a newer version of sinatra.

gem 'sinatra', '2.0.0.beta2'