なるようになるブログ

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

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

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

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

activerecord/CHANGELOG.md


Merge pull request #23570 from rthbound/addresses-23568

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

accepts_nested_attributes_forを使用している場合に、associtaionに存在しないアトリビュートを指定して保存しようとした際にのエラーメッセージで、エラーメッセージに表示されるクラス名 / アトリビュート名が親クラスの情報になっていたのを、正しく子associationの情報を表示するよう修正しています。

issueより。

# before
Dashboard.new(measures_attributes: [{stinky: "yup"}])
#=> ActiveModel::UnknownAttributeError: unknown attribute 'measures_attributes' for Dashboard.

# after
Dashboard.new.measures_attributes = [{stinky: "yup"}]
#=> ActiveModel::UnknownAttributeError: unknown attribute 'stinky' for Measure.

Merge pull request #22365 from phuibonhoa/phuibonhoa/polymorphic_where_multiple_types

Active Recordの修正です。

polymorphic associationsを使用している場合に、whereに異なるtypeのインスタンスを含むしたArrayを渡した場合に、正しく処理が行われないバグがあったのを修正しています。

CHANGELOGより。

PriceEstimate.where(estimate_of: [Treasure.find(1), Car.find(2)])
# => SELECT "price_estimates".* FROM "price_estimates"
     WHERE (("price_estimates"."estimate_of_type" = 'Treasure' AND "price_estimates"."estimate_of_id" = 1)
     OR ("price_estimates"."estimate_of_type" = 'Car' AND "price_estimates"."estimate_of_id" = 2))

partially revert 69009f4473637a44ade26d954ef5ddea6ff903f2

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

ActionController::Metal#response_body=メソッドで、メソッド内でbodyのresponseへのwrite処理を行うようにしていたのを、write処理は行わずresponse.bodyにbodyへのセット処理だけを行うよう修正しています。

ここでwrite処理を行ってしまうと、Fiber basedのstreaming templatesの処理が正しく行われない為との事です。


Remove accidentally duplicated change log title [ci skip]

activerecord/CHANGELOG.mdの修正です。

Merge pull request #22365 from phuibonhoa/phuibonhoa/polymorphic_where_multiple_types で誤ってCHANGELOGに同じentryのタイトルが記載されてしまったので、片方削除しています。


Fix indentation for code block in changelog

activerecord/CHANGELOG.mdの修正です。

Merge pull request #22365 from phuibonhoa/phuibonhoa/polymorphic_where_multiple_typesで追加されたentryのコードexampleが正しくcode blockとして表示されるよう、インデントを調整しています。


fields_for_style needs to test for AC::Parameters https://github.com/rails/rails/commit/04b410f83350aa8a9b6f181cc7c37f2c2653300f

actionpack/test/controller/parameters/parameters_permit_test.rbの修正です。

ActionController::Parameters#fields_for_style?メソッドで@parametersParameters`クラスかどうかもチェックするよう修正しています。

-        @parameters.all? { |k, v| k =~ /\A-?\d+\z/ && v.is_a?(Hash) }
+        @parameters.all? { |k, v| k =~ /\A-?\d+\z/ && (v.is_a?(Hash) || v.is_a?(Parameters)) }

ActionController::Parametersのhashの中に更にActionController::Parametersインスタンスがいた場合に、正しくチェック処理が行われないバグがあった為、対応したとの事です。


Add accidentally removed # [ci skip]

activerecord/CHANGELOG.mdの修正です。

Fix indentation for code block in changelogで誤ってexampleの実行結果からコメント(#)を削除してしまってのを、戻しています。


Merge pull request #23736 from kamipo/remove_needless_case_insensitive_comparison_in_mysql2_adapter

activerecord/lib/active_record/connection_adapters/abstract_adapter.rbactiverecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rbの修正です。

mysql2 adapterから不要なcase_insensitive_comparisonメソッドを削除しています。


Fix the language in engines guide

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

Generating an Article Resourceの項、説明対象のcontroller名をタイポしている箇所があったのを修正しています。


set skip_listen option to dummy appplication

railties/lib/rails/generators/rails/plugin/plugin_generator.rbの修正です。

pluginのtest配下に生成されるdummy aplicationのデフォルトにskip_listenを追加しています。

元々、ファイルの更新監視にlistenを使用したActiveSupport::EventedFileUpdateCheckerを使用するようになっていたのですが、pluginのgemspecにはlistenを使用するよう指定が行われておらず、dummy appplicationで何か処理を行おうとするとエラーになってしまっていたのでデフォルトではActiveSupport::EventedFileUpdateCheckerを無効になるように、skip_listenオプションを追加しています。


Missing documentation about hash algorithm option for MessageVerifier [ci skip]

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

MessageVerifierクラスのdocに、hashアルゴリズムのデフォルトはSHA1であることと、変更したい場合はdigestオプションを指定すれば変更出来る旨説明を追加しています。