Basic steps to start a rails app that will be hosted in a remote server and heroku, using sqlite3 in development and PostgreSQL in Heroku

Overview

Basic steps to start a rails app that will be hosted in a remote server and heroku, using sqlite3 in development and PostgreSQL in production (heroku).

Generate a new app


$ rails _5.0.0_ new sample_app

Adjust Gemfile

Inspect /sample_app/Gemfile and put sqlite3 in the development group and postgresql in production group.

#...
group :development, :test do
  gem 'sqlite3', '1.3.11'
  #...
end

group :production do
  gem 'pg', '0.18.4'
end

Install gems

Install the gems specified in development, skipping production gems with bundle install --without production.


$ cd sample_app
sample_app$ bundle install --without production
sample_app$ bundle update

Initialize Git repository

Start control versioning the project


sample_app$ git init
sample_app$  git commit -m "Init repo"

Add Github repo

Set a new remote to github


sample_app$ git remote add origin https://github.com/user/sample_app.git
sample_app$ git push -u origin --all

Deploy to Heroku

Pushing and deploying the application to Heroku.


sample_app$ heroku create
sample_app$ git push heroku master

Useful commands

Migrating the database.


sample_app$ rails db:migrate

Running the test suite to verify that everything is working.


sample_app$ rails test

Run the app in a local server:


sample_app$ rails server

Uruguay
Marcelo Canina
I'm Marcelo Canina, a developer from Uruguay. I build websites and web-based applications from the ground up and share what I learn here.