Guides‎ > ‎

Heroku

This was done on Ubuntu 12.04.

Create an account on the Heroku site.
Install the heroku toolbelt. I  did "gem install heroku foreman" but they have native installers too on https://toolbelt.heroku.com/.
$ heroku login
$ heroku keys:add path/to/ssh-key.pub # you can leave off the path if it's in the default location

Install postgres. On ubuntu:
$ sudo apt-get install postgresql postgresql-contrib libpq-dev
$ sudo -u postgres createuser --superuser rails
$ sudo -u postgres psql postgres -c '\password rails' # I set the password to rails
$ createdb -h localhost -U rails rails_development
$ createdb -h localhost -U rails rails_test
$ psql -h localhost -U rails rails_development -c "SELECT * FROM foo;" # confirm db, user, & password work

Create a rails project based on https://devcenter.heroku.com/articles/rails3

$ nano .env
Add lines:
RACK_ENV=development
DATABASE_URL=postgres://rails:rails@localhost:5432/rails_development
$ echo "#Foreman uses .env" >> .gitignore
$ echo "/.env" >> .gitignore

$ nano config/database.yml
development:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: rails_development
  pool: 5
  username: rails
  password: rails
test:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: rails_test
  pool: 5
  username: rails
  password: rails

Then the workflow is:
$ git pull # from main repo
$ foreman start # to run local development server
hack hack hack
look at http://localhost:5000/
$ foreman run rails console # if needed
$ foreman run rake db:migrate # if needed
$ git commit -a ...
$ git push # to main repo
$ git push heroku # deploys to heroku
$ heroku run rake db:migrate # if needed
$ heroku open # to see production site
Comments