LoginSignup
7
5

More than 5 years have passed since last update.

Rails 5 (api mode) セットアップメモ

Last updated at Posted at 2016-08-19

参考

http://maetoo11.hatenablog.com/entry/2016/03/04/144216
http://morizyun.github.io/blog/rails-api-5.0.0.beta.2/

手順

準備

プロジェクトルートのディレクトリを作成

$ mkdir abc
$ cd abc

rubyのversionを確認。使いたいバージョンにしておく。
rbenv使ってたので、こんな感じ

# 確認
$ ruby -v
$ rbenv versions

# 設定
$ rbenv global 2.3.1
$ rbenv rehash

(この時点からglobalじゃなくてlocalってすればいいのかも)

railsのインストールまで

$ bundle init

Gemfileに以下の行を追加. 使いたいrailsのバージョンで。
gem 'rails', '5.0.0.1'

で、インストール
bash
$ bundle install --path vendor/bundle --jobs=4

終わったらgitにコミットしたくなったので、git initして一旦vendor/をignoreして、コミットした。

$ git init
$ vi .gitignore
# /vendor を追加
$ git add .
$ git commit -m 'Initial commit (installing rails)'

rails new

apiモードでnewした。 DBはmysqlで

bundle exec rails new . --api -d mysql

.gitignoreさっき作っちゃったからconflictとかでたけど、全部上書き。
あとで/vendorは足し直した。

APIモードで入っているのを確認して、commit

$ git add .
$ git commit -m 'Rails new --api'

さっきrbenvをlocalにしてなかったので、ここでやった。

$ rbenv local 2.3.1
# .ruby-version が作成される
$ git add .
$ git commit -m 'Add ruby-version'
7
5
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
7
5