Ruby on Rails is a popular web framework written in Ruby. In this artical covers using Rails 4 on Heroku. The many step for deploying Rails 4 to Heroku below:
1. Installation heroku environment (www.toolbelt.heroku.com) – if you not yet have
Open your terminal and type command below:
1. wget -qO- https://toolbelt.heroku.com/install.sh | sh
2. gem install heroku foreman
3. heroku login
2. Installation git – if you not yet have
Open your terminal and type command below:
1. sudo apt-get install git-core
2. sudo apt-get install expat openssl zlib1g zlib1g-dev
3. Create Ruby on Rails project
Open your terminal and type command below:
rails new app_name -d postgresql
Go into you project, Open your terminal and type command below:
cd app_name
We will first create a controller called welcome for our home page to live, Open your terminal and type command below:
rails generate controller welcome
Next then add an index page in directory app/views/welcome/index.html.erb
1 2 3 4 5 |
|
We need to have Rails route to index action. We’ll edit config/routes.rb
1
|
|
Let run the rails app and visiting http://localhost:3000 in your browser, Open your terminal and type command below:
rails server
Then open Gemfile and add gems below at the end:
gem 'heroku'
gem 'thin'
gem 'rails_12factor', group: :production
Then open your terminal and type command below:
bundle install
Rails 4 requires Ruby 1.9.3 or above. Heroku has a recent version of Ruby installed, however you can specify an exact version by using the ruby DSL in your Gemfile by adding ruby “2.1.1” at the end of Gemfile.
ruby "2.1.1"
4. Deploy to heroku
Open your terminal and type command below:
1. cd project_name
2. git init
3. git add .
4. git commit -m “my first commit”
5. heroku create heroku_app_name
6. heroku git:remote -a heroku_app_name
7. git push heroku master
Each time you wish to deploy to Heroku
Open your terminal and type command below:
1. git add -A
2. git commit -m “commit for deploy to heroku”
3. git push -f heroku
So far so good, You now have your first application deployed to Heroku. The next step is to deploy your own application. :)