How To upload a Rails app to Heroku
1 First, configure your app to use PostgreSQL: Edit your Gemfile to change the line :
gem 'sqlite3'
To this:
gem 'pg'
and execute:
$ bundle install
2 Second, use git to create a local repository:
$ git init
$ git add .
$ git commit -m "new app"
3 Third, install Heroku gem, if it isn’t installed yet:
$ gem install heroku
$ heroku list
4 Now create the Heroku app:
$ heroku create
$ git push heroku master
$ heroku run rake db:migrate
5 To rename the default Heroku app name:
$ heroku rename <newname>
6 To create a custom domain for the app:
$ heroku addons:add cutom_domains
$ heroku domains:add <new.domain.com>
Next steps
- Develop and test locally
- Commit to git every change
- Push to Heroku with: $ git push heroku master
Utilities
- Rename Heroku app $ heroku rename
- Custom domain $ heroku addons:add custom_domains $ heroku domains:add
- Add the following text to Gemfile to user Thin server instead of WebBrick: gem ‘thin’
- How to install PostgreSQL on Mac
- Sample file config/database.yml to use PostgreSQL:
development:
adapter: postgresql
encoding: unicode
database: blog_development
pool: 5
username: <set $USER>
password:
host: localhost
test:
adapter: postgresql
encoding: unicode
database: blog_test
pool: 5
username: <set $USER>
password:
host: localhost
For Heroku production: entry is not necessary, because Heroku assigns one PostgreSQL to each app.