なるようになるブログ

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

rails commit log流し読み(2017/07/17)

2017/07/17分のコミットです。

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

activesupport/CHANGELOG.md

activerecord/CHANGELOG.md


Fix code formatting for QueryMethods#select

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

QueryMethods#selectメソッドのdocのフォーマットの修正を行っています。


explain why require_relative is not used here [ci skip]

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

retrieve_store_classメソッドでrequire_relativeではなくrequireを使用している理由についての説明を追加しています。


Fix root not being defined on Travis.

railties/lib/rails/test_unit/reporter.rbの修正です。

TestUnitReporter#app_rootメソッドでRails.rootを取得する前に、Railsrootメソッドが定義されているか確認するよう修正しています。

railsの各コンポーネントのテストを実行する際、Rails moduleは定義されているが、rootメソッドが定義されていない事がありえる為。


Merge pull request #29819 from kirs/frozen-activemodel

Active Modelの修正です。

各ファイルの先頭にfrozen_string_literal: trueを追加しています。


Set RAILS_ENV before load application file

railties/lib/rails/commands/dbconsole/dbconsole_command.rbの修正です。

require_application_and_environment!メソッドを呼び出す前に

ENV["RAILS_ENV"]に値を設定するよう修正しています。RAILS_ENVに値を設定する前にconfig/applicationを読み込みむとデフォルトのenv(development)のファイルが読み込まれてしまう為。


Enable Layout/FirstParameterIndentation cop

.rubocop.ymlLayout/FirstParameterIndentation copを追加、及び各ファイルにcopを反映しています。


Remove useless arel_engine

Active Recordの修正です。

不要なarel_engineメソッドを削除しています。

元々、arel_engineメソッドはFinderMethods#raise_record_not_found_exception!メソッドでのみ使用していたのですが、engineではなくklass.connectionを渡しても正常に動作する為、削除したとの事です。


Merge pull request #28077 from Erol/make-reverse-merge-bang-order-consistent

activesupport/lib/active_support/core_ext/hash/reverse_merge.rbactivesupport/lib/active_support/hash_with_indifferent_access.rbの修正です。

Hash#reverse_merge!メソッドの結果のオーダーが、Hash#reverse_mergeHashWithIndifferentAccess#reverse_merge、#reverse_merge!`と異なっていたのを、全て同じオーダーになるよう修正しています。

# before
ab = {a: 1, b: 2}
c = {c: 3}

indifferent_ab = HashWithIndifferentAccess.new(a: 1, b: 2)
indifferent_c = HashWithIndifferentAccess.new(c: 3)

ab.reverse_merge(c) #=> {c: 3, a: 1, b: 2}
ab.reverse_merge!(c) #=> {a: 1, b: 2, c: 3}
indifferent_ab.reverse_merge(c) #=> {c: 3, a: 1, b: 2}
indifferent_ab.reverse_merge!(c) #=> {c: 3, a: 1, b: 2}

# after
ab.reverse_merge!(c) #=> {c: 3, a: 1, b: 2}

Post.joins(:users) should not be affected by User.current_scope

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

Relation#joinsでtarget modelのcurrent_scopeに影響を受けないよう修正しています。ただ、unscopedの情報については使用されるようになっています。


Add documentation for class_attribute options

activesupport/lib/active_support/core_ext/class/attribute.rbのdocの修正です。

class_attributeメソッドのdocにオプションについての説明を追加しています。