ひさしぶりにRailsで開発をしよう
なんだかプログラムを書きたくなったのです。
Rubyを2.1.6から2.3系へ
brewがぶっ壊れているのでなおす。El Capitanにした影響の模様。
$ cd /usr/local $ git reset --hard && git clean -df $ sudo chown -R $(whoami):admin /usr/local $ brew doctor
brewを更新してrbenvを更新してRubyを更新という流れ。
$ brew update $ brew upgrade ruby-build $ rbenv install --list
リストを見て2.3.1を選択。インストール。
$ rbenv install 2.3.1 $ rbenv global 2.3.1 $ rbenv rehash $ rbenv versions
Ruby on Railsのインストール
Ruby2.3.1ではrailsコマンド効かないので。
$ gem install rails --no-ri --no-doc
nokogiriがどうとか。
下記を参照してMac OS X 10.11 El Capitan用のコマンド実行。
http://www.ericluwj.com/2015/10/29/installing-ruby-on-rails-on-osx.html
$ gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 --use-system-libraries
1 gem installed と出て完了。
再度Railsのインストール。
$ gem install rails --no-ri --no-doc Successfully installed rails-4.2.6 1 gem installed
とのこと。Rails4.2.6に。
動作確認
sampleプロジェクトを作って表示してみる。
$ rails new sample --skip-test-unit --skip-turbolinks --skip-bundle $ cd sample $ bundle install --without production $ rails g scaffold friend name:string $ rake db:migrate $ rails s
ブラウザで以下を確認
http://localhost:3000
http://localhost:3000/friends
問題なし。
RubyMineで使用するRubyのVerのデフォルトも変更しておく。