『改訂4版 基礎Ruby on Rails』読者サポートページ
2018/04/01
このページは、オイアクス社監修の『改訂4版 基礎Ruby on Rails』(2018年9月7日刊行)の読者サポートページです。
本書では、Railsはバージョン5.2.0、Rubyはバージョン2.5.1を使っています。
本書で誤字、脱字、内容の間違いなどを見つけた方は、[email protected] までご連絡ください。
サンプルソース
ZIPファイル: https://pub.oiax.jp/rails5book/source-v2.zip
参考情報
正誤表
MySQLを利用したい場合
まず、次のページを参考にしてMySQLをインストールしてください。
- https://programmingnavi.com/35/ (macOS)
- https://www.yokoweb.net/2018/05/13/ubuntu-18_04-server-mysql/ (Ubuntu 18.04)
テキストエディタで Gemfile を開き、gem 'sqlite3' と書かれた行を次のように書き換えます。
gem 'mysql2'
そして、ターミナルで次のコマンドを実行します。
$ bundle
さらに、テキストエディタで config/database.yml を開き、全体を削除してから、次の内容を記入します。ただし、PASSWORD の部分はMySQLのインストール時に設定した root ユーザーのパスワードで置き換えてください。
default: &default
  adapter: mysql2
  encoding: utf8
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: root
  password: PASSWORD
  host: localhost
development:
  <<: *default
  database: asagao_development
test:
  <<: *default
  database: asagao_test
production:
  <<: *default
  database: asagao_production
PostgreSQLを利用したい場合
まず、次のページを参考にしてPostgreSQLをインストールしてください。
- http://vdeep.net/mac-postgresql (macOS)
- https://www.server-world.info/query?os=Ubuntu_18.04&p=postgresql&f=1 (Ubuntu 18.04)
テキストエディタで Gemfile を開き、gem 'sqlite3' と書かれた行を次のように書き換えます。
gem 'pg'
そして、ターミナルで次のコマンドを実行します。
$ bundle
さらに、テキストエディタで config/database.yml を開き、全体を削除してから、次の内容を記入します。ただし、PASSWORD の部分はMySQLのインストール時に設定した postgres ユーザーのパスワードで置き換えてください。パスワードを設定していない場合は、PASSWORD の部分を削除してください。
default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: postgres
  password: PASSWORD
  host: localhost
development:
  <<: *default
  database: asagao_development
test:
  <<: *default
  database: asagao_test
production:
  <<: *default
  database: asagao_production
 
  