なるようになるブログ

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

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

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

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

railties/CHANGELOG.md


Remove redundant instances of the word ‘simply’ from documentation, on the basis that if it was simple, the user wouldn’t be reading the docs

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

各項のグラマーの修正を行っています。


Merge pull request #29770 from y-yagi/fix_boolean_column_migration_script

Active Recordの修正です。

SQLite 3 adapterでbooleanの値を保持するのにStringのt / fを使用していたのを、Integer(1 / 0)を使用するよう移行する為のスクリプトにタイポがあったのを修正しています。


Merge pull request #29769 from kamipo/remove_extra_order_for_first

Active Recordのテストの修正です。

テストでレコードの最初の行を取得するのに、all.merge!(order: "id").firstorderしていたのを、単純にfirstを使用するよう修正しています。

Made `first` finder consistent among database engines by adding a default order clause からRelation#firstはprimary keyでorderした値を返すようになっており、明示的にorderする必要は無い為。


Merge pull request #29679 from kamipo/add_test_case_for_27724

activerecord/test/cases/associations/has_many_through_associations_test.rbの修正です。

associationに既に存在しているconditionを上書き出来る事を確認するテストを追加しています。


Remove blank lines in setup

railties/lib/rails/generators/rails/app/templates/bin/setup.ttの修正です。

bin/setupbin/yarnを実行する処理の後に不要な空行があったのを削除しています。


Do not generate unused components contents in app:update task

railtiesの修正です。

app:update taskで、使用していないコンポーネントに関するファイル、configは生成しないよう修正しています。

元々はアプリの状態に関わらず全てのファイル、configを生成するようになっていたのですが、例えば--skip-action-cableを指定して作成したアプリの場合、Action Cablenに関するファイル、configは生成しないようになります。


Merge pull request #29771 from kamipo/fix_create_with_using_both_string_and_symbol

Active Recordの修正です。

create_withに同じkeyをString、Symbolでそれぞれで指定した場合に、後から設定した値が正しく反映されないバグがあったのを修正しています。


Merge pull request #29809 from kamipo/remove_unused_ivars

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

ActiveRecord::Relation#resetメソッドから使用していない変数を削除しています。


Remove unused requires

activerecord/lib/active_record/attribute_methods.rbactiverecord/lib/active_record/core.rbの修正です。

使用していないファイルのrequireを削除しています。


Set represent_boolean_as_integer via configuration

Active Recordの修正です。

SQLite 3 adapterでbooleanの値を保持するのに、String又はIntegerを使用するかを指定する為のフラグをconfig経由で指定出来るよう修正しています。

元々はActiveRecord::ConnectionAdapters::SQLite3Adapterのattributeを直接参照するようになっていたのですが、ActiveRecord::ConnectionAdapters::SQLite3Adapterはinitiaiizer実行時点ではloadされておらず、initiaiizerから値が設定出来ない為、config経由で値を指定出来るようにしています。


add helper method for explicit lazy load

railties/test/application/configuration_test.rbの修正です。

lazy load hookを呼び出す為のヘルパーメソッドを追加しています。


Fix create_with with multiparameter attributes

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

create_withメソッドにmultiparameter attributes(date型のwritten_on(1i)written_on(2i)等)を指定出来るよう修正しています。


Don’t cache scope_for_create

Active Recordの修正です。

scope_for_createの結果をcacheしていたのを、cacheしないよう修正しています。通常の処理でcacheされたscope_for_createが使われる事は無く、cacheする意味が無いため。


Allow to pass a connection to the dbconsole command

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

dbconsoleコマンドでconnection name(DB configファイルの3階層目の値)を指定出来るよう修正しています。

bin/rails dbconsole -c replicaのように、-cオプション経由で指定出来るようになっています。


Deprecate environment as an argument for dbconsole and console

railties/lib/rails/command/environment_argument.rbの修正です。

dbconsoleconsoleコマンドのregular argumentとしてenvironment’s nameを指定するのがdeprecateになりました。今後はenvironment’s nameを指定するのに必ず-eオプションを指定する必要があります。

# before
$ bin/rails dbconsole production

# after
$ bin/rails dbconsole -e production

Properly expand the environment’s name

railtiesの修正です。

dbconsoleconsoleコマンドの-eオプションでenvironment’s nameを指定する際に、自動で補完(prodと指定した場合、productionにしてくれる)するよう修正しています。


Replace Erubis with Erubi in a part of guide [ci skip]

rails guideのThe Rails Initialization Processの修正です。

Railsが依存しているgemの一覧にerubisが残っていたのを、erubiに修正しています。