なるようになるブログ

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

rails commit log流し読み(2016/08/31)

2016/08/31分のコミットです。

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

activerecord/CHANGELOG.md


Update typo & Make explanation more clear

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

各項のタイポ、及びフォーマットの修正を行っています。


Merge pull request #23498 from jcoleman/remove-unnecessary-belongs-to-load

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

ActiveRecord::AutosaveAssociation#save_belongs_to_associationでassociationがload済み、かつ、foreign keyが直接設定されている場合に、不要なsave処理が行われないよう修正しています。


[ci skip] Broken links in documentation fix

rails guide内の、404になってしまっていたリンクを修正しています。


use message that specified in argument to error message

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

assert_changesメソッドで、assertionに失敗した場合に表示するエラーメッセージにmessage引数を使用しない場合があったのを、使用するよう修正しています。


Refactor remove duplication.

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

ActiveRecord::Persistence#destroy#create_or_updateそれぞれで行っていたreadonly recordの場合のエラーのraise処理をメソッド(_raise_readonly_record_error)に切り出しています。


Ensure that inverse associations are set before running callbacks

Active Recordの修正です。

inverse associationsのインスタンスafter_findafter_initialize callbacksが実行される前に必ず設定するよう修正しています。

callback実行前にインスタンスを設定しないと、callback内でインスタンスにアクセスした際にstack overflowが発生してしまう問題がある為、修正したとの事です。


Merge pull request #26282 from kamipo/add_type_default_value

Active Recordの修正です。

typeのdefault valueを作成するのに、各箇所でそれぞれType::Value.newインスタンスを作成していたのを、default valueを作成する為のメソッドを(Type.default_value)作成し、そちらを使用するよう修正しています。

変数を使いまわしして、インスタンスの生成を抑える為との事です。


Merge pull request #26283 from kamipo/use_splat_hash_for_options

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

ActiveRecord::Associations#has_and_belongs_to_manyメソッドのoptions引数にsplatを使用するよう修正しています。

-        def has_and_belongs_to_many(name, scope = nil, options = {}, &extension)
-          if scope.is_a?(Hash)
-            options = scope
-            scope   = nil
-          end
-
+        def has_and_belongs_to_many(name, scope = nil, **options, &extension)