Quick guides for starting a new Ruby on Rails app from scratch

Create new app, set up development pipeline, push updates, and install Bootstrap

Note: The following guides assume your development environment is already set up, including Ruby, Rails, database, version control, and deployment. For these examples, I will use PostgreSQL, GitHub, and Heroku.

Create new Ruby on Rails app

rails new appname --database=postgresql

2. Adjust config/database.yml and connect database

  • Add the following under default (where postgres is database username and password is database password):
username: postgres
password: password
host: localhost
  • Also, comment out login under production
# username: appname

3. Navigate to the new app folder (cd appname) and create database

rake db:create

4. Start Rails server

rails s

5. In your browser, navigate to http://localhost:3000/. You should see a page similar to the image below.

Image for post
Image for post

Set up development pipeline

git init

2. Stage everything in current folder

git add --all

3. Make the first commit of application code

git commit -am “Initial commit”

4. Set up GitHub

  • Log in to GitHub
  • Create a new repository
  • Run commands provided to “push an existing repository from the command line” using SSH

5. Set up Heroku

  • Create Heroku app
heroku create [appname]
  • Push to Heroku
git push heroku master

Update to GitHub

git add --all

2. Commit staged files and add a comment describing the changes

git commit -am "[comment]"

3. Push commit(s) to GitHub

git push origin master

Update to Heroku

git push heroku master

Install Bootstrap

  • Add gem 'jquery-rails' to Gemfile and run bundle install
  • Open assets/javascripts/application.js and add the following above turbolinks:
//= require jquery
//= require jquery_ujs

2. Add popper_js and bootstrap to your Gemfile

gem 'popper_js', '~> 1.14.5'
gem 'bootstrap', '>= 4.3.1'
source 'https://rails-assets.org' do
gem 'rails-assets-tether', '>= 1.3.3'

(Note: The versions shown are the most recent at the time of writing. Check for updated versions and adjust your Gemfile accordingly)

3. Run bundle install and restart your server to make the files available through the pipeline

4. Rename application.css to application.scss

mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss

5. Make a new file at app/assets/stylesheets/master.scss and add the following code into it:

@import “bootstrap”;

6. Adjust app/assets/javascripts/application.js to include the following between turbolinks and require_tree:

//= require popper
//= require tether
//= require bootstrap-sprockets

Any suggestions for improving these guides are welcome! I’m trying to keep the steps concise while still including enough information.

Danny Poit is a web developer with experience in Ruby on Rails and Node.js and a background in film scoring. Grad of Firehose Project, Colt Steele, and Berklee.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store