環境
- rbenv 1.1.0
- ruby 2.4.0
プロジェクトの作成
# ディレクトリを作成して移動
$ mkdir sample; cd $_
# Gemfileの作成
$ bundle init
Writing new Gemfile to /Users/your_name/sample/Gemfile
$ ls
Gemfile
$
Gemfileを編集してRailsをインストール
$ vi Gemfile
編集前
# frozen_string_literal: true
source "https://rubygems.org"
# gem "rails"
編集後 ( # gem "rails"
の #
を削除)
# frozen_string_literal: true
source "https://rubygems.org"
gem "rails"
$ bundle install --path vendor/bundle --jobs=4
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Resolving dependencies...
Installing i18n 0.8.1
# (略)
Installing rails 5.0.2
Bundle complete! 1 Gemfile dependency, 38 gems now installed.
Bundled gems are installed into ./vendor/bundle.
$ ls
Gemfile Gemfile.lock vendor/
プロジェクトの作成
$ bundle exec rails new -B -O --skip-turbolinks .
exist
create README.md
create Rakefile
# (略)
$ ls -la
total 48
drwxr-xr-x 20 your_name staff 680 4 24 11:31 ./
drwxr-xr-x 27 your_name staff 918 4 24 10:52 ../
drwxr-xr-x 3 your_name staff 102 4 24 11:18 .bundle/
-rw-r--r-- 1 your_name staff 468 4 24 11:30 .gitignore
drwxr-xr-x 7 your_name staff 238 4 24 11:33 .idea/
-rw-r--r-- 1 your_name staff 1682 4 24 11:30 Gemfile
-rw-r--r-- 1 your_name staff 2702 4 24 11:19 Gemfile.lock
-rw-r--r-- 1 your_name staff 374 4 24 11:30 README.md
-rw-r--r-- 1 your_name staff 227 4 24 11:30 Rakefile
drwxr-xr-x 10 your_name staff 340 4 24 11:30 app/
drwxr-xr-x 7 your_name staff 238 4 24 11:30 bin/
drwxr-xr-x 13 your_name staff 442 4 24 11:30 config/
-rw-r--r-- 1 your_name staff 130 4 24 11:30 config.ru
drwxr-xr-x 3 your_name staff 102 4 24 11:30 db/
drwxr-xr-x 4 your_name staff 136 4 24 11:30 lib/
drwxr-xr-x 3 your_name staff 102 4 24 11:30 log/
drwxr-xr-x 9 your_name staff 306 4 24 11:30 public/
drwxr-xr-x 9 your_name staff 306 4 24 11:30 test/
drwxr-xr-x 4 your_name staff 136 4 24 11:30 tmp/
drwxr-xr-x 4 your_name staff 136 4 24 11:30 vendor/
$
今回の使用したオプションは、
-
-B
→bundle install
を実行しない -
-O
→ DBを使用しない -
--skip-turbolinks
→ turbolinksを使用しない -
.
APP_PATHには今いるディレクトリを指定して作成
その他のオプションについては bundle exec rails new -h
で確認できます。
新規Railsプロジェクトの作成はこんな感じ
コピペ用にコマンドだけ抜粋
mkdir sample; cd $_
bundle init
vi Gemfile
bundle install --path vendor/bundle --jobs=4
bundle exec rails new -B -O --skip-turbolinks .