0
0

More than 3 years have passed since last update.

bundleを使ったrailsプロジェクトの初期化

Last updated at Posted at 2020-01-11

ruby, railsコマンドのインストール

rubyコマンドも、railsコマンドもprojectで管理したい。こちらを参考にした。

$ mkdir project_dir && cd project_dir
$ bundle init

$ vim Gemfile
* gem "rails"のアンコメントを外す

$ bundle install --path vendor/bundle
$ bundle exec rails new . -d postgresql -T

Overwrite /path/to/Gemfile? (enter "h" for help)
$ y

$ vim Gemfile
* group :developmentに gem 'rubocop', require: false を追加
$ bundle install

$ vim .rubocop.yml で以下を書き込む
Style/FrozenStringLiteralComment:
  Enabled: false

$ rails webpacker:install
  • vendor/bundle内にrubyもrailsも他のgemも入る。(一回目のbundle installでpathを指定した)。今後はコマンドは$ bundle exec (実行コマンド)を使う。

.bundle/configの設定変更(引用)

bundle execで純粋にプロジェクトローカルのgemだけを使用するには、
.bundle/configのBUNDLE_DISABLE_SHARED_GEMSを"true"にすること。
"false"の場合、vender/bundle配下に存在しないgemをRubyグローバルから探してくる。

$ vim .bundle/config
.bundle/config
---
BUNDLE_PATH: "vendor/bundle"
BUNDLE_DISABLE_SHARED_GEMS: "true"  #ここを"true"

Gitにpush

$ vim .gitignore => /vendor/bundle/ を追加
$ git add .
$ git commit -m "first commit"
$ git remote add origin (gitのurl)
$ git push -u origin master

webpackでbootstrap4の導入(参考)

$ yarn add bootstrap jquery popper.js
.....
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0