『改訂3版 基礎Ruby on Rails』(2015年5月、インプレス刊)のサンプルソースです。
書籍情報:http://book.impress.co.jp/books/1114101096
Amazon:http://www.amazon.co.jp/dp/4844338153/
読者サポートページ:http://www.oiax.jp/rails4book
Ruby 2.2.1または2.2.2、Ruby on Rails 4.2.1
Windowsでは、Ruby 2.1.5または2.1.6をお使いください。
次のどちらかでソースコードを入手できます。
gitコマンドのgit cloneを使う。
% git clone [email protected]:oiax/asagao4.git
- 右の「Download ZIP」よりZIPファイルをダウンロードして展開する。
フォルダchapter1、chapter3からchapter7、section8-1からsection9-5の中にRailsのプログラムがあります。
サンプルを実行したい章、節のフォルダに移動して、bundleコマンドを実行してください。
mac:~ taro% cd asagao4/chapter3
mac:chapter3 taro% bundle install
Chapter 4以降では、Rakeのdb:resetタスクで、データベースの初期化を行ってください。
mac:chapter4 taro% bin/rake db:reset
bin/rails sコマンドでRailsプログラムが起動します。
mac:chapter4 taro% bin/rails s
Windowsでは、bundleコマンドを実行する前に、DevKitとSSL証明書の設定を行ってください(本書23-24ページを参照)。
C:¥asagao4¥chapter4> C:¥devkit¥devkitvars
C:¥asagao4¥chapter4> set SSL_CERT_FILE=C:¥Users¥taro¥cacert.pem
C:¥asagao4¥chapter4> bundle install
bin/で始まるコマンドの前にはrubyを付けてください
C:¥asagao4¥chapter4> ruby bin/rake db:reset
C:¥asagao4¥chapter4> ruby bin/rails s