2016/08/31分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Remove unnecessarily association load when a
belongs_to
association has already been loaded then the foreign key is changed directly and the record saved. - Inverse association instances will now be set before
after_find
orafter_initialize
callbacks are run.
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
引数を使用しない場合があったのを、使用するよう修正しています。
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_find
、after_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)