なるようになるブログ

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

rails commit log流し読み(2015/11/07)

2015/11/07分のコミットです。

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

activerecord/CHANGELOG.md

activesupport/CHANGELOG.md


call local_cache 1 time instead of 3 times

activesupport/lib/active_support/cache/strategy/local_cache.rbの修正です。

LocalCache#read_entryメソッドで、local_cacheメソッド複数回呼んでいたのを、一度呼んだ結果を変数に保持するようにし、メソッド呼び出しを一度だけで済むよう修正しています。


Clarify automatic creation/deletion of join models for has_many through

rails guideのActive Record Associationsの修正です。

The has_many :through Associationの項の文中にhas_many association methodsへのリンクを追加、及びグラマーの修正を行っています。


use prepend instead of extending every instance

Active Supportのcache処理の修正です。

各cache storeクラスでStrategy::LocalCache moduleを追加するのに、インスタンス生成時extendを使用して行っていたのを、prependメソッドでクラスに追加するよう修正しています。


Avoids mutating the original response in connection management middleware

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

ActiveRecord::ConnectionManagement#callメソッドでresponseを返す際、元のresponseを変化させていたのを止めて、新規にresponseを生成し値を返すよう修正しています。

元の実装だとメモリリークになってしまう恐れがあるのと、元のresponseがfreezeされた値だった場合にエラーになってしまう為、修正したとの事です。


Suppress warning (warning about assigned but unused variable)

activerecord/test/cases/connection_management_test.rbの修正です。

元のresponseが変更されない事を確認するテストから、使用していない変数(response_body)を削除しています。


Fix wrong assert_equal argument order.

activerecord/test/cases/connection_management_test.rbの修正です。

assert_equalメソッドの引数の順番が間違っている(expected, actualの順番が正しい順番だが、逆だった)箇所があったのを修正しています。


Add comma to to make the information clear

rails guideのForm Helpersの修正です。

Dealing with Ajaxの項、最初の説明の中にカンマを追加しています。


Parameterize with options to preserve case of string

activesupport/lib/active_support/core_ext/string/inflections.rbactivesupport/lib/active_support/inflector/transliterate.rbの修正です。

String#parameterizeActiveSupport::Inflector#parameterizeメソッドの引数にキーワード引数を使用するよう修正、及び、大文字小文字の変換を行わないよう設定する為のpreserve_caseオプションを追加しています。

"Donald E. Knuth".parameterize(preserve_case: true)
# => "Donald-E-Knuth"
"Donald E. Knuth".parameterize
# => "donald-e-knuth"

また、今後separatorの指定はseparatorオプションを使用する必要があります。

"Donald E. Knuth".parameterize('_')
# => DEPRECATION WARNING: Passing the separator argument as a positional parameter is deprecated and will soon be removed. Use `separator: '_'` instead. (called from __pry__ at (pry):9)
# => "donald_e_knuth"

"Donald E. Knuth".parameterize(separator: '_')
# => => "donald_e_knuth"

remove deprecated :tokenizer option from guide [ci skip]

rails guideのActive Record Validationsの修正です。

length helperについて説明している箇所から、deprecatedになった:tokenizerオプションについての説明を削除しています。


Merge pull request #22145 from atul-shimpi/master

rails guideのActive Record Migrationsの修正です。

Column Modifiersの項から、requiredオプションについての説明を削除しています。

Require belongs_to by default. by simi · Pull Request #18937 · rails/railsrequired オプションはデフォルトtrueになり、オプションを使用する必要が無くなった為。