Get your Ruby-Sinatra App on Heroku

Get your Ruby-Sinatra App on HerokuKenneth StewartBlockedUnblockFollowFollowingJun 11I couldn’t find any clear guides to launching Ruby-Sinatra apps on Heroku so I decided to write one.

The first step you’ll need to take is create a Heroku account.

That’s fairly straight-forward so I wont get into it.

Once you’ve done that you will want to go into command line and install a bundler and heroku.

First the bundler:gem install bundler.

Then install heroku:brew install heroku/brew/herokuYou will then be prompted to log into Heroku by the command-line.

Once you’ve done that you should create a new Heroku repository.

heroku createYour Heroku Project will the be given a random name — Adj + Geographical-Feature.

You should also be able to see it if you go to >> https://dashboard.

heroku.

com/apps.

Now that you have that set-up you will need to add a couple files to your project to tell Heroku how to run it.

You will need to touch 3 new files in the command line: config.

ru | Procfile | GemfileThe only gems I am using in my Gemfile are ‘pg’ and ‘sinatra’, so my gemfile looks like this.

source ‘https://rubygems.

org'gem ‘sinatra’gem ‘pg’, ‘~> 0.

18’The congfig.

ru file is also very simple.

It looks like this:run Sinatra::ApplicationNext is Procfile.

This gives Heroku the commands it will need to run your app.

This should include the command you type into your command line to run your app locally.

web: bundle exec ruby app.

rb -p $PORT‘app.

rb’ is my main controller file, if yours isn’t named ‘app.

rb’ you will need to change it.

Only a few more steps to go.

Back in command line you will need to do a bundle install to setup a Gemfile.

lock.

bundle installYou should now have a Gemfile.

lock in your folder.

It should look like this:You can now launch to Heroku!.First add, commit and push all your files to github and then push to Heroku with the following command:git push heroku masterNow, your app probably won’t be working at this point.