なるようになるブログ

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

rails commit log流し読み(2016/01/22)

2016/01/22分のコミットです。

CHANGELOGへの追加はありませんでした。


- Fix warning introduced in https://github.com/vipulnsward/rails/commit/77acc004efad07dfd4d4f83be14ef897968a3fd9 when fixing API responses.

actionpack/test/controller/api/renderers_test.rbの修正です。

Rails APIのテストで、deprecateになったget :textを使用している箇所があり、deprecateメッセージが表示されてしまっていたので、該当のテストをassert_deprecatedで囲んで対応しています。


[ci skip] fix #23157

rails guideのGetting Started with Railsの修正です。

Generating a Modelの項、migrationファイルにおける:referencesキーワードについての説明を追加しています。


Use bind parameters for ranges in where clauses

Active Recordの修正です。

where句にRangeクラスを指定した場合に、bind parametersを使用するよう修正しています。

Do not cache prepared statements that are unlikely to have cache hitsSQLinを含む場合にプリペアドステートメントを内部的にキャッシュしないよう修正されたのですが、その際の対応漏れのようです。


Merge pull request #23078 from y-yagi/add_application_mailer_rb_to_mountable_engine

Railtiesの修正です。

rails engineを新規作成する際、mailerの親クラス(ApplicationMailer)を生成するよう修正しています。


Fix ActionController::Parameters#== bug

actionpack/lib/action_controller/metal/strong_parameters.rbの修正です。

HashActionController::Parameters==で比較した際に、正しく比較処理が行われるよう修正しています。

hash = { foo: :bar }
params = ActionController::Parameters.new(hash)

params == hash  #=> 元々falseになってしまっていたのがtrueになった

==メソッドで、引数がHashだった場合、HashWithIndifferentAccessに変換してから比較処理を行うようにして対応を行っています。


Remove action_cable_meta_tag when skip action_cable

railties/lib/rails/generators/rails/app/app_generator.rbの修正です。

rails newに--skip-action-cableを指定した際に、不要なAction Cableのメソッドの呼び出し(action_cable_meta_tag)が残ってしまっていたのを削除しています。


Add config/cable.yml to list of default files in Rails generator

railties/test/generators/app_generator_test.rbの修正です。

Railsがデフォルトで生成するファイルの一覧にconfig/cable.ymlを追加しています。


Merge pull request #23080 from prathamesh-sonpatki/fix-cache-key-for-loaded-empty-collection

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

ActiveRecord::Relation#cache_keyメソッドで、collectionがload済み、かつ、collectionの数が0だった場合にエラーになっていたのを対応しています。

      if collection.loaded?
         size = collection.size
-        timestamp = collection.max_by(&timestamp_column).public_send(timestamp_column)
+        if size > 0
+          timestamp = collection.max_by(&timestamp_column).public_send(timestamp_column)
+        end

collectionの数が0だった場合に、max_byの戻り値がnilになるのですがnilに対してpublic_sendを呼びだそうとしてエラーになってしまっていたとの事です。collectionの数が0の場合は、該当の処理を行わないようにして対応しています。


First pass over parts of Testing guide

rails guideのA Guide to Testing Rails Applicationsの修正です。

全体的なグラマーの修正、assert_sendメソッドのexampleの追加等をまとめて行っています。


rm changelog for unreleased changes fixes

actionpack/CHANGELOG.mdの修正です。

4.2からの変更ではない不要なentryがあったのを削除しています。


remove per_form_csrf_tokens initializer from Rails API

railties/lib/rails/generators/rails/app/app_generator.rbの修正です。

Rails APIではper_form_csrf_tokens initializer(form毎に異なるCSRF tokenが生成するかどうかを指定するためのinitializer)が生成されないよう修正しています。 Rails APIではform無い為、


[ci skip] Add note about tsrange and timezone awareness to docs

activerecord/lib/active_record/timestamp.rbのdocの修正です。

Timestamp moduleのdocに、ActiveRecord::Base.time_zone_aware_types(timezoneを使用する型を指定する為のattribute)についての説明を追加しています。