Heroku deploy Rails in 5 minutes
In this post I will show, how you can easily getting started to deploy your Ruby on Rails project in Heroku. Heroku is free cloud platform as service (PaaS), and they bet to easily project deployment service.
This guide is helpful only for those who are trying Heroku at first time! We will skip Active Record begin on this project, when we could better only test Heroku for Rails.
If you are not yet registered to Heroku, do it now:
https://id.heroku.com/signup.
I was using Ruby 1.9.3p484 and Rails 4.0.0 on Ubuntu 13.10 64-bit.
1. Create new Rails project
And generate welcome controller with index action:
$ rails new hello-heroku --skip-active-record
$ cd hello-heroku
$ rails g controller welcome indexAdd to root routing from config/routes.rb:
$ nano config/routes.rbUncomment next line:
root 'welcome#index'Heroku require that you modify little bit your project /bin files (bundle, rails, rake) shebang.
Change:
#!/usr/bin/env ruby1.9.1to
#!/usr/bin/env ruby1.1. Heroku Procfile
Create new Procfile on project root for Heroku:
$ nano ProcfileAnd write next code in file Procfile:
web: bundle exec rails server -p $PORT1.2. Initialize Git
$ git initDo first commit:
$ git add .
$ git commit -m "first commit"2. Heroku
Is time to install heroku toolbelt:
$ wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | shLogin to Heroku:
$ heroku login2.1. Create new Heroku app
$ heroku createPush your project to Heroku:
$ git push heroku master3. Test
Open your Heroku App to browser:
$ heroku openIf your browser opened page looks like next:
Welcome#index
Find me in app/views/welcome/index.html.erbYou are successfully deploy your Rails app in Heroku!
Source
https://toolbelt.heroku.com/
https://devcenter.heroku.com/articles/getting-started-with-rails4