2018/04/21分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Introduce ActionDispatch::DebugExceptions.register_interceptor
- Introduce a new error page to when the implict render page is accessed in the browser.
- Add
touch_all
method toActiveRecord::Relation
. - Add support to preload associations of polymorphic associations when not all the records have the requested associations.
Merge pull request #23868 from gsamokovarov/debug-exceptions-interceptors
actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
の修正です。
ActionDispatch::DebugExceptions
にinterceptorを登録出来るようにしています。
interceptorはregister_interceptor
メソッドを使用して登録出来るようになっており、登録されたinterceptorはException発生時に実行されます。
ActionDispatch::DebugExceptions.register_interceptor do |request, exception| HypoteticalPlugin.capture_exception(request, exception) end
[ci skip] Improve #find_in documentation.
railties/lib/rails/source_annotation_extractor.rb
のdocの修正です。
SourceAnnotationExtractor#find_in
メソッドのdocで、アノテーションの対象となるファイルの拡張子をベタで記載していたのを、Rails::SourceAnnotationExtractor::Annotation.extensions
で取得出来る値が対象である旨説明を修正しています。
元々記載されいたのではRailsがデフォルトで対応している拡張子だけだったのですが、実際は各gemによりもっと異なる拡張子が登録されており、誤解を招くだろうということで修正されています。
[ci skip] Prefix class name with Rails:: in docs
railties/lib/rails/source_annotation_extractor.rb
のdocの修正です。
各メソッドのdoc内のexampleコードで、deprecateになった古いクラスSourceAnnotationExtractor
が使用されていたのを、新しいクラス(Rails::SourceAnnotationExtractor
)を使用するよう修正しています。
Don't include bootsnap by default in apps generated under JRuby
railties/lib/rails/generators/app_base.rb
の修正です。
JRubyを使用している場合に、rails new
で生成されるGemfileにbootsnap
を含まないよう修正しています。
bootsnap
はJRubyをサポートしていない為。
Merge pull request #32572 from nao0515ki/add_optional_true_to_self_joins_section
rails guideのActive Record Associations
の修正です。
Self Joins
の項にあるexampleコード内のbelongs_to
を使用している箇所に、optional
オプションの指定が不足していたのを修正しています。
Merge pull request #29286 from vinistock/create_missing_exact_template_exception
Action Packの修正です。
ブラウザからのアクセス、かつ、renderするテンプレートが内場合にraiseするエラークラスをActionController::UnknownFormat
からActionController::MissingExactTemplate
に変更しています。
また、デフォルトのエラーテンプレートにActionController::MissingExactTemplate
用のテンプレートを追加し、ActionController::MissingExactTemplate
が発生した場合に適切なエラーページを表示するよう修正しています。
Merge pull request #31513 from fatkodima/relation-touch_all
activerecord/lib/active_record/relation.rb
、
activerecord/lib/active_record/timestamp.rb
の修正です。
ActiveRecord::Relation
にtouch_all
メソッドを追加しています。
例。
Person.where(name: "David").touch_all(time: Time.current)
Can preload associations through polymorphic associations
activerecord/lib/active_record/associations/preloader.rb
の修正です。
polymorphic association経由でassociationをpreloadする場合、対象となるassociationが存在しなくてもエラーにならないよう修正しています。
例。
class Review < ActiveRecord::Base has_many :media, polymorphic: true end class Movie < ActiveRecord::Base has_one :director end class Book < ActiveRecord::Base has_one :author end
上記のようなクラス構成で、media
がMovie
、または、Bookのどちらかになる場合に、
media+ その先のassociationをまとめてpreloadしようとすると(
Review.includes(media: [:author, :director]))エラー(
ActiveRecord::AssociationNotFoundError`)になっていました。で、これをエラーとせず、まとめてpreload出来るよう修正しています。
Relax assertions in connection config tests
activerecord/test/cases/connection_adapters/connection_handler_test.rb
の修正です。
connection configのテストがbin/test
ツールを使うとエラーになっていたのを、エラーにならないよう修正しています。
rake test
を実行した場合は問題無かったのですが、bin/test
を使うとRails.root
が定義されてしまい、その影響で結果が異なるようになってしまっていました。
Fix typo in the touch_all
doc [ci skip]
activerecord/lib/active_record/relation.rb
のdocの修正です。
Relation#touch_all
メソッドのdoc内のexampleコードでtouch
メソッドを使用していたのを、touch_all
メソッドを使用するよう修正しています。
Add test case for collection.size
with dirty target
activerecord/test/cases/associations/has_many_associations_test.rb
の修正です。
dirty targetを含むcollectionに対するsize
メソッドのテストを追加しています。
target
in CollectionAssociation
is always an array
activerecord/lib/active_record/associations/collection_association.rb
の修正です。
CollectionAssociation#size
メソッドでtarget
がArray
かどうかチェックしていたのを、チェックしないよう修正しています。CollectionAssociation
ではtarget
は必ずArray
の為。