Looking for Ruby developers?
Contact Us

How to deploy sinatra on heroku | Inkoop Blog

Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort. We talk about how to deploy sinatra application on heroku which provides a free server.

Posted by Ameena on 12 Mar 2018
How to deploy sinatra on heroku | Inkoop Blog

Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort.

If you already have a sinatra app, use it or go ahead and create one and add below code which basically has sinatra routes.


#web.rb

  get '/' do
    'Hey there!'
  end

You need a Procfile file alongside your config.ru to tell Heroku how to run your app.

Example content of Procfile

web: bundle exec ruby web.rb -p $PORT

What this says is that run a web process on the port Heroku gives you using the bundle environment.

Sample config.ru

$:.unshift File.expand_path("../", __FILE__)
require 'rubygems'
require 'sinatra'
require './web

run Sinatra::Application
  • Array#unshift will prepend the new path to $:

  • File#expand_path is considered to be Ruby idiom for getting the absolute path to a file when you know the path relative to the current file.

Voila!

Keep Coding !!!

Ameena


Looking for Ruby developers?
Contact Us

Related Services.



Hire ReactJS Developers
Hire Gatsby Developers
Hire NextJS Developers

We support the Open Source community.



Have a Project in mind?