なるようになるブログ

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

rails commit log流し読み(2016/02/21)

2016/02/21分のコミットです。

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

activesupport/CHANGELOG.md

activerecord/CHANGELOG.md


Make collection caching explicit.

Action Viewのcache処理の修正です。

元々自動で行っていたcollectionのcache処理を、cachedオプションが指定された場合のみ行うよう修正しています。

# before
<%= render partial: 'notifications/notification', collection: @notifications %>

# after
<%= render partial: 'notifications/notification', collection: @notifications, cached: true %>

Revert "Instrument read_multi".

cacheを複数読みこんだ際に、その詳細を出力するよう対応した、Instrument read_multi. · rails/rails@ca6aba7をrevertしています。cacheを複数読み込んだ際に出力するログの内容を変更する為、一旦revertしたとの事です。


Mutating the result of Relation#to_a should not affect the relation

Active Recordの修正です。

ActiveRecord::Relation#to_aが元々loadしたRelation自身を返していたのを、dupした値を返すよう修正しています。

# before 
def to_a
  load
  @records
end
# after
def to_a
  records.dup
end

def records # :nodoc:
  load
  @records
end

to_aを呼び出した時点で元のRelationに影響を与えないようにする為、との事です。


Instrument cached collection renders.

Action Viewのcache処理の修正です。

キャッシュしたcollectionをrenderする際、キャッシュのヒット率を表示するよう修正しています。

<%= render partial: 'notifications/notification', collection: @notifications, cached: true %>

上記のようなcollectionのキャッシュを表示する際、下記ログが出力されます。

Rendered collection of notifications/_notification.html.erb [0 / 100 cache hits] (3396.5ms)

Make benchmark('something', silence: true) actually work

activesupport/lib/active_support/benchmarkable.rbの修正です。

benchmarkメソッドsilencetrueオプションを指定した場合に、エラーになってしまうバグがあったのを修正しています。

-        ms = Benchmark.ms { result = options[:silence] ? silence { yield } : yield }
+        ms = Benchmark.ms { result = options[:silence] ? logger.silence { yield } : yield }

まだこういう初歩的なバグ残ってるんですねえ。


use method provided by minitest

railties/lib/rails/test_unit/reporter.rbの修正です。

テストが失敗した際、失敗したテストの詳細情報を出力するのに独自メソッド(#format_failures)を使用していたのを、minitestが提供しているメソッド(Test#to_s)を使用するよう修正しています。

行っている処理が同じだった為。


Fixed typo

actioncable/lib/action_cable/channel/periodic_timers.rbのdocの修正です。

periodicallyメソッドのdoc内のタイポを修正しています。