###Downloads
-
Begin by downloading and installing The Heroku Toolkit via [MacOSX] or [Ubuntu]. (If you havent done so already) (The Toolkit includes Heroku Command Line utility, as well as git and Foreman.)
-
Install the Bundler gem for Ruby. ( Learn about [Bundler] )
$ gem install bundler
- Add rails_12factor gem to your gemfile
gem 'rails_12factor', group: :production
- Bundle your gems
$ bundle
... which should return something like this:
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
###Deployment
- Now Login to Heroku. If not created, manually create a SSH Key.
$ heroku login
Enter your Heroku credentials.
Email: [email protected]
Password:
Could not find an existing public key.
Would you like to generate one? [Yn]
Generating new SSH public key.
Uploading ssh public key /Users/adam/.ssh/id_rsa.pub
- Create a new web application
$ heroku create
Creating murmuring-galaxy-997... done, stack is cedar
http://murmuring-galaxy-997.herokuapp.com/ | [email protected]:murmuring-galaxy-997.git
Git remote heroku added
- Connect your local repository to the Heroku repository
$ heroku git:remote -a murmuring-galaxy-997
Git remote heroku added.
- Push your code to Heroku
$ git add .
$ git commit -m "first deployment to heroku"
$ git push heroku master
- Migrate your tables. Seed if required.
$ Heroku run rake db:migrate
$ Heroku run rake db:seed
- Check that your app has successfully deployed by reviewing status with logs
$ heroku logs
By default Heroku doesn't serve assets (eg images). Enable asset service:
#app/config/production.rb
config.serve_static_assets = false
config.assets.compile = false
#change these to true:
config.serve_static_assets = true
config.assets.compile = true
Confirm your app has deployed by viewing it in the browser
$ heroku open
Rename your app to something more userfriendly
$ heroku apps:rename newname
Further reading: [Tutorial] bundle exec rake assets:precompile [Tutorial]:http://railsapps.github.io/rails-heroku-tutorial.html [Bundler]:http:bundler.io [MacOSX]:https://toolbelt.heroku.com/ [Ubuntu]:https://toolbelt.heroku.com/
Additional commands:
$ heroku pg:reset DATABASE
$ heroku run rake db:migrate db:seed