Run Sinatra along with Rails

Sinatra is much better than rails for writing API codes and small functionalities, We can run sinatra app inside rails application.

Write your sinatra codes inside library folder of rails application, you can call rails application database tables from sinatra app also.

Then on your rails app

# This file is used by Rack-based servers to start the application.

require ::File.expand_path(‘../config/environment’, __FILE__)

require_relative ‘lib/api’

map ‘/api’ do

map ‘/’ do
run Rails.application

Put this code, so normal request goes to rails controller and  request url with /api goes to sinatra app. This way we can use both rails app and sinatra app together.