Heroku – Ruby on Rails

System preparation

apt install curl git gnupg2 nodejs

Install RVM

Go to the site rvm.io and look at the installation commands:

gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable

Add a user to the group:

vim /etc/group

My username in the systemubuntu


Then from the user:

source /etc/profile.d/rvm.sh

Find out the version of RVM:

rvm --version

View a list of Ruby versions available for installation:

rvm list known

Install the latest version of Ruby:

rvm install "ruby-2.5.1"

The list of installed Ruby versions and the default can be found as follows:

rvm list

Let’s see the gem version and update it:

gem -v
gem update --system


gem install rails


Create application

Create a test application:

rails new example_app -T

Go to the directory of our application:

cd example_app

Let’s create for the test index.html

vim public/index.html


Insert there the following:

<!DOCTYPE html>
Example Ruby App


Run for test on all interfaces:

bundle exec rails s -p 3000 -b ''

=> Booting Puma
=> Rails 5.2.2 application starting in development 
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://
Use Ctrl-C to stop


Check in the browser:

Where is the IP address of the computer where the application is running

If the computer has a graphical shell, you can omit the IP address when launching the application, and enter the browser by localhost. Also without graphics, the localhost can be checked with a cursor or a console browser.

You can stop the application – Ctrl-C



Being in the root of our application, we initialize the repository:

git init

Reinitialized existing Git repository in /home/ubuntu/heroku/example_app/.git/

Check status:

git status

On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)


nothing added to commit but untracked files present (use "git add" to track)


Add all files:

git add .


And we are doing a commit:

git commit -am "Add Ruby files to repo"



git status

On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   .gitignore
        new file:   .ruby-version
        new file:   Gemfile
        new file:   Gemfile.lock
        new file:   README.md
        new file:   Rakefile
        new file:   app/assets/config/manifest.js
        new file:   app/assets/images/.keep
        new file:   app/assets/javascripts/application.js
        new file:   app/assets/javascripts/cable.js
        new file:   app/assets/javascripts/channels/.keep
        new file:   app/assets/stylesheets/application.css
        new file:   app/channels/application_cable/channel.rb
        new file:   app/channels/application_cable/connection.rb
        new file:   app/controllers/application_controller.rb
        new file:   app/controllers/concerns/.keep
        new file:   app/helpers/application_helper.rb
        new file:   app/jobs/application_job.rb
        new file:   app/mailers/application_mailer.rb
        new file:   app/models/application_record.rb
        new file:   app/models/concerns/.keep
        new file:   app/views/layouts/application.html.erb
        new file:   app/views/layouts/mailer.html.erb
        new file:   app/views/layouts/mailer.text.erb
        new file:   bin/bundle
        new file:   bin/rails
        new file:   bin/rake
        new file:   bin/setup
        new file:   bin/spring
        new file:   bin/update
        new file:   bin/yarn
        new file:   config.ru
        new file:   config/application.rb
        new file:   config/boot.rb
        new file:   config/cable.yml
        new file:   config/credentials.yml.enc
        new file:   config/database.yml
        new file:   config/environment.rb
        new file:   config/environments/development.rb
        new file:   config/environments/production.rb
        new file:   config/environments/test.rb
        new file:   config/initializers/application_controller_renderer.rb
        new file:   config/initializers/assets.rb
        new file:   config/initializers/backtrace_silencers.rb
        new file:   config/initializers/content_security_policy.rb
        new file:   config/initializers/cookies_serializer.rb
        new file:   config/initializers/filter_parameter_logging.rb
        new file:   config/initializers/inflections.rb
        new file:   config/initializers/mime_types.rb
        new file:   config/initializers/wrap_parameters.rb
        new file:   config/locales/en.yml
        new file:   config/puma.rb
        new file:   config/routes.rb
        new file:   config/spring.rb
        new file:   config/storage.yml
        new file:   db/seeds.rb
        new file:   lib/assets/.keep
        new file:   lib/tasks/.keep
        new file:   log/.keep
        new file:   package.json
        new file:   public/404.html
        new file:   public/422.html
        new file:   public/500.html
        new file:   public/apple-touch-icon-precomposed.png
        new file:   public/apple-touch-icon.png
        new file:   public/favicon.ico
        new file:   public/index.html
        new file:   public/robots.txt
        new file:   storage/.keep
        new file:   tmp/.keep
        new file:   vendor/.keep



We register on heroku.com and go to the account.

For the convenience of working with Heroku, install their CLI


sudo snap install --classic heroku

Installation for distributions other than Ubuntu can be viewed on the website Heroku


heroku --version

heroku/7.19.4 linux-x64 node-v11.3.0

Log in to Heroku CLI:

heroku login

We press any key and get the authorization URL, copy it to the browser, log in.

Let’s create an application on Heroku:

heroku create

Creating app... done, ⬢ my-generated-app-name-83844
https://my-generated-app-name-83844.herokuapp.com/ | https://git.heroku.com/my-generated-app-name-83844.git

Now in the Gemfile it is necessary to replace "sqlite3" with "postgres", otherwise Heroku will give the following error:

remote: An error occurred while installing sqlite3 (1.3.13), and Bundler cannot
remote: continue.
remote: Make sure that `gem install sqlite3 -v '1.3.13'` succeeds before bundling.
remote: In Gemfile:
remote: sqlite3
remote: !
remote: ! Failed to install gems via Bundler.
remote: ! Detected sqlite3 gem which is not supported on Heroku:
remote: ! https://devcenter.heroku.com/articles/sqlite3
remote: !
remote: ! Push rejected, failed to compile Ruby app.

Open Gemfile

vim Gemfile

Find at the beginning of the file record of sqlite3

gem 'sqlite3'

And we transfer it to the block "group :development, :test do"

To get the following:

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'sqlite3'

Before this block, add a new block:

group :production do
  gem 'pg'

Save changes to the file.

Reinstall without postgres.

bundle install --without production

Add files, commit and push to Heroku:

git add .
git commit -am "Heroku"
git push heroku master


heroku open

In response, we get the URL by which we can check the application on Heroku.

Tagged: Tags

Notify of

Inline Feedbacks
View all comments