ぽっぽ屋

Railsプロジェクト作成手順

流れは覚えているけど、細かいコマンドやオプションを忘れることがあるのでメモ
bundle install--path vendor/bundleは付ける派

環境

  • Ubuntu Server 18.04 LTS
  • rbenv 使用
  • binstubs 使用

プロジェクト用フォルダ作成

$ mkdir {project name}; cd $_

Bundler 設定追加

$ bundle config --local bin 'vendor/bin'
$ bundle config --local path 'vendor/bundle'

# 確認
$ bundle config --local
Settings are listed in order of priority. The top value will be used.
bin
Set for your local app (/home/vagrant/applications/scheduler/.bundle/config): "vendor/bin"

path
Set for your local app (/home/vagrant/applications/scheduler/.bundle/config): "vendor/bundle"

Gemfile 生成

$ bundle init

Rails インストール

$ vi Gemfile
# gem "rails" のコメントアウトを解除

$ bundle install

プロジェクト作成

Rails 6.1以降なら --minimal オプションが使える
指定オプションについて:

  • DBはMySQL(-d mysql
  • 標準のテストではなく、Rspecを使用(--skip-test
  • APIモード(--api
  • 最小構成(--minimal
$ rails new . -d mysql --skip-test --api --minimal
Overwrite /home/[user_name]/applications/[project_name]/Gemfile? (enter "h" for help) [Ynaqdhm] y
はとぽっぽ丸

はとぽっぽ丸

プログラマー5年目