Deploy Rails to Heroku
Follow these 12 steps for deploying your app on heroku.
- Create a new Heroku account.
- In the terminal, log in using the email address and password of Heroku account:
$ heroku login - In Gemfile, add the
pggem to your Rails project. Change: -
gem sqliteto
-
gem 'sqlite3', group: :development gem 'pg', '0.18.1', group: :production - In Gemfile, add the
rails_12factorgem::gem 'rails_12factor', group: :production - In gem file write ***** ruby ‘>=2.2’ ******. so that heroku use correct version of ruby.
- In the terminal, install the gems using:
$ bundle install - Check config/database.yml is using the
postgresqladapter. Change:production: <<: *default database: db/production.sqlite3to
production: <<: *default adapter: postgresql database: db/production.sqlite3 - Commit your changes to git:
$ git add . $ git commit -m "My first Commit" - In the terminal, create an app on Heroku:
$ heroku create - Push your code to Heroku:
$ git push heroku master - If you are using the database in your application, migrate the database by running:
$ heroku run rake db:migrate - If you need to seed your database with data, run:
$ heroku run rake db:seed - Get the URL of your app and visit it in the browser:
$ heroku apps:infoThis will open your app on browser.

Leave a comment