A beginner guide to deploy Rails application to Heroku
Many beginners want to deploy their simple application on production environment, but they do not get any free cloud service. So what they can do? Well, there is a solution provided by Heroku. Heroku is a cloud platform as a service supporting several programming languages that is used as a web application deployment model.
So, let’s get started!
Step 1. Install Git version control system.
$ git –version
git version 2.9.2
$ git config --global user.name "Foo Bar" $ git config --global email@example.com
Congratulation! you have Git on your system. The next step is to create Ruby on Rails application.
Step 2. Create Ruby on Rails application.
$ git commit –m “Initialize repository”
Step 3. Setup Bit-bucket remote repository.
You also can use GitHub remote repository, but there is a problem, GitHub does not provide free private repositories while Bit-bucket does.
$ git remote add origin firstname.lastname@example.org:/ $ git push -u origin –all
Step 4. Deploy application to Heroku.
Heroku uses the PostgreSQL as production database, which means that we need to add the 'pg gem' in the production environment to allow Rails to talk to PostgreSQL. Open Gem file and below group.
group :production do gem 'pg', '0.20.0' end
To prepare the project for deployment, we run bundle install with a special flag to prevent the local installation of any production gems.
$ bundle install --without production
Next, we have to create and configure a new Heroku account.
$ heroku version
$ heroku login $ herokukeys:add
$ heroku create
To see your newly deployed application, visit the address that you saw when you run heroku create.