Follow heroku tutorials:
https://devcenter.heroku.com/articles/getting-started-with-rails4
1, new rails app
rails new albertly --database=postgresql
2, setup the database
rake db:setup
rake db:migrate
rake db:setup
3, add a gem for heroku
gem 'rails_12factor', group: :production bundle install