shou2017.com
JP

My Personal Setup Process for Rails New on Local Environment

Fri Nov 16, 2018
Sat Aug 10, 2024

This is a note on what I think is the minimum essential setup when creating a new Rails project locally.

Manage gems per Rails project

Create a Gemfile with bundle init

$ mkdir myapp
$ cd myapp
$ bundle init 

Edit the Gemfile

# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'rails', '~> 5.2.1'

Next, run bundle install --path vendor/bundle. For subsequent installations, the --path vendor/bundle option is not necessary.

$ bundle install --path vendor/bundle

Rails new

Adjust options according to your preferences.

Since I often use Heroku, I set the database to postgresql.

I usually use RSpec for testing, so I use the --skip-test option to disable the default Minitest.

The ーB, --skip-bundle option prevents the Rails project creation from running bundle install.

$ bundle exec rails new . -B -d postgresql --skip-test

Finally, I set up git and, in my case, RubyMine configuration to complete the process.

$ git init
$ git add .
$ git commit -m "first commit"
See Also