1.Xcodeをインストールする
2.Command Line Tools をインストールする
xcode-select --install
3.Homebrewをインストールする
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
4.MacPortsでインストールしている「Ruby」をアンインストールする
sudo port uninstall ruby
5.「RVM」をアンイストールする
rvm implode
6.「rbenv」と「ruby-build」をインストールする
brew link autoconf brew install rbenv ruby-build echo 'eval "$(rbenv init -)"' >> ~/.bash_profile source ~/.bash_profile
7.Ruby 2.2.2をインストールする
rbenv install 2.2.2 rbenv global 2.2.2
8.rubyのバージョンを確認する
ruby -v
9.gemrcを作成する
vi ~/.gemrc
テキストエディタでi
でINSERTモードにする
install: --no-ri --no-rdoc update: --no-ri --no-rdoc
を書き込む。
:wq
で保存する
10.Bundlerをインストールする(gemがホームディレクトリに入る)
gem install bundler
11.Bundler のバージョンを確認する
bundle -v
12.ワークディレクトリを作成して移動する(作業ディレクトリに入れる)
cd work/ruby_test/
13.Gemfileを編集する
vi Gemfile
テキストエディタでi
でINSERTモードにする
source 'http://rubygems.org' gem 'rails', '4.2.3'
を書き込む。
:wq
で保存する
※Gemfileの先頭に、インストール元はhttp://rubygems.orgと宣言する
続けてインストールしたいgemを記述する。バージョンの指定4.2.3を記述する。
14.Rails 4.2.3 のインストール
Gemfileにリスト化したgemを一括インストールする。
bundle install --path=vendor/bundle
15.ターミナルで Ruby on Rails のバージョンを確認する。
bundle exec rails -v
を打つと「Rails 4.2.3」と出ること
16.ワークディレクトリに移動する
cd work/ruby_test/
17.Railsプロジェクトを作成する
bundle exec rails new .
でカレントディレクトリにRailsプロジェクトを作成
18.Gemfileを上書きしますか?と聞かれるので
Y
を入力する。
Overwrite /Users/non/work/ruby_test/Gemfile? (enter "h" for help) [Ynaqdh] Y
19.Railsを起動する
bundle exec rails c
または
bundle exec rails console
Running via Spring preloader in process 45717
Loading development environment (Rails 4.2.3)
と表示される