Rails New Project
bundler + rails の環境構築メモ
前提
- rubyおよびbundlerはインストール済みであること
- gemのインストール先は
vendor/bundle
とする
手順
ディレクトリを作り移動してbundle init
でGemfileを作る
% mkdir <new_project_dir> % cd <new_project_dir> % bundle init
Gemfileを編集してgem "rails"
を加える
(コメントアウトされているので行頭の#
を取り除く)
# frozen_string_literal: true source "https://rubygems.org" git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } gem "rails"
Railsをインストール
% bundle install --path=vendor/bundle
現在のディレクトリをRailsのプロジェクトディレクトリとして初期化
(Gemfileがコンフリクトするので--force
で上書き)
% bundle exec rails new . --skip-bundle --force
(必要に応じてGemfileを編集する)
gemをインストールする
% bundle install --path=vendor/bundle --without=production
.gitignoreにvender/bundle
を追加する
# Ignore bundle-path /vendor/bundle
gitに最初のコミットを行う
% git add .
% git commit -m 'initial commit'