なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2015/08/05)

2015/08/05分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

railties/CHANGELOG.md


Merge pull request #21112 from kamipo/fix_mysql2_version

activerecord/lib/active_record/connection_adapters/mysql2_adapter.rbの修正です。

Mysql2Adapterが返すバージョンの情報が、MySQLサーバのバージョンではなくクライアントのバージョンを返してしまっていたのを、正しくMySQLサーバのバージョン情報を返すよう修正しています。

-        @full_version ||= @connection.info[:version]
+        @full_version ||= @connection.server_info[:version]

呼び出すメソッドが間違ってしまっていた為。


Add rake dev:cache task to enable dev mode caching.

railtiesの修正です。

development環境で、cacheの有効化/無効化を容易に行う為のdev:cache rakeを追加しています。

dev:cacheを実行すると、tmp配下にcaching-dev.txtという空のファイルが生成され、このファイルがある場合、cacheが有効とみなされます。

cacheの内容はconfig/environments/development.rbに定義されています。デフォルトでは下記の通り。

# config/environments/development.rb

# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
  config.action_controller.perform_caching = true
  config.static_cache_control = "public, max-age=172800"
  config.cache_store = :memory_store
else
  config.action_controller.perform_caching = false
  config.cache_store = :null_store
end

static_cache_controlが設定される感じです。

また、rakeタスク以外にも、同様にcacheを有効化/無効化するオプション(-C--[no-]dev-caching)がrails serverコマンドに追加されています。

Usage: rails server [mongrel, thin etc] [options]
    -p, --port=port                  Runs Rails on the specified port.
                                     Default: 3000
    -b, --binding=IP                 Binds Rails to the specified IP.
                                     Default: localhost
    -c, --config=file                Uses a custom rackup configuration.
    -d, --daemon                     Runs server as a Daemon.
    -e, --environment=name           Specifies the environment to run this server under (test/development/production).
                                     Default: development
    -P, --pid=pid                    Specifies the PID file.
                                     Default: tmp/pids/server.pid
    -C, --[no-]dev-caching           Specifies whether to perform caching in development.
                                     true or false

    -h, --help                       Shows this help message.

これだと簡単に使えそうで良いですねえ。 オプションを指定された場合、dev:cacheタスク同様caching-dev.txtファイルの作成/削除が行われます。