Install the gem:
gem install rails
Create a new project and
cd into it:
rails new ProjectTest
Heroku works with PostgreSQL as backend database as it doesn’t support SQLite3, so you’ll have to add the
pg gem in the Gemfile in a
group :production do
IMPORTANT: After adding PostgreSQL to the production group in the Gemfile you’ll have to move the SQLite3 gem to a development group or delete it, if you work with PostgreSQL just delete it entirely but if you would like to keep SQLite3 for local development then move the gem to a dev group like this:
group :development do
This way Heroku won’t touch the SQLite3 gem.
Lets update Bundler and install the gems excluding the production group:
bundle install --without production
Open the terminal and proceed with the installation script:
wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
After that, enter your Heroku credentials:
And add you
We’ll get back to Heroku later, we have to make some changes to our code first.
Heroku doesn’t support the default index page of Rails, so let’s write a Hello World! as our index page to confirm it’s deploying correctly to Heroku.
Generate a controller with our index page:
rails generate controller Welcome index
Now open app/views/welcome/index.html.erb and change your index page as you like, for example:
<p>Yup! The deployment is working. Checkout <a href="https://codingodse.info">CodingDose()</a></p>
Open the routes file in config/routes.rb and change the line:
This is how the file should look:
Fire up the server with (
s stands for
Go to http://localhost:3000/ and your index should be displaying
Newer versions of Rails add a git repository, unless there’s no repository initialized you will have to do it yourself with
git init, then add the files and commit them:
git add .
git commit -am "initialize repository"
First, create a domain on heroku:
And lets push the new repo to heroku’s servers:
git push heroku master
There you go, you setup a new Rails project, version control and a succesful deployment to Heroku :)