Yu-Chieh’s Blog (Y.C. Chang)

Ruby on Rails / Rubygems / FullStack / Git / Mac notes.

Rails App Deploy to Heroku : An Easy Way

Preparing step

  • install Postgres DB via brew
1
2
3
4
5
6
7
8
9
10
11
$ brew doctor
$ brew update
$ brew install postgresql

# if we want to run pg locally, we need to run the following instructions.

# To have launchd start postgresql at login:
ln -sfv /usr/local/opt/postgresql/*plist ~/Library/LaunchAgents

# Then to load and run postgresql immediately:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
1
2
$ heroku login
$ heroku create
  • Open the file called Gemfile in your text editor and find the line containing:
1
gem 'sqlite3'
  • Remove that line and replace it with:
1
2
3
4
5
6
7
8
group :development, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
  gem 'rails_12factor'
end
  • bundle install
1
$ bundle install --without production
  • git add . and git commit
1
2
$ git add .
$ git commit -m "Changed Gemfile for heroku"
  • finally, push to heroku
1
2
$ git push heroku master
$ heroku run rake db:migrate

Comments