Deploy Rails to Heroku

1–2 minutes

read

Deploy Rails to Heroku

Follow these 12 steps for deploying your app on heroku.

  1. Create a new Heroku account.
  2. In the terminal, log in using the email address and password of Heroku account:
    $ heroku login
    
  3. In Gemfile, add the pg gem to your Rails project. Change:
  4. gem sqlite
    

    to

  5. gem 'sqlite3', group: :development
    gem 'pg', '0.18.1', group: :production
    
  6. In Gemfile, add the rails_12factor gem::
    gem 'rails_12factor', group: :production
    
  7. In gem file write  *****  ruby ‘>=2.2’ ******. so that heroku use correct version of ruby.
  8. In the terminal, install the gems using:
    $ bundle install
    
  9. Check config/database.yml is using the postgresql adapter. Change:
    production:
      <<: *default
      database: db/production.sqlite3
    

    to

    production:
      <<: *default
      adapter: postgresql
      database: db/production.sqlite3
    
  10. Commit your changes to git:
    $ git add .
    $ git commit -m "My first Commit"
    
  11. In the terminal, create an app on Heroku:
    $ heroku create
    
  12. Push your code to Heroku:
    $ git push heroku master
    
  13. If you are using the database in your application, migrate the database by running:
    $ heroku run rake db:migrate
    
  14. If you need to seed your database with data, run:
    $ heroku run rake db:seed
    
  15. Get the URL of your app and visit it in the browser:
    $ heroku apps:info
    

    This will open your app on browser.

 

 

 

 

 

 

 

Leave a comment