なるようになるブログ

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

rails commit log流し読み(2019/04/03)

2019/04/03分のコミットです。

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

activerecord/CHANGELOG.md


Merge pull request #35768 from robertomiranda/r/rake-db-prepare

activerecord/lib/active_record/railties/databases.rakeの修正です。

DBが無ければsetupを、DBがあればmigrateを実行するdb:prepare taskを追加しています。

bin/updatebin/setupを1つにまとめる予定(Factorize bin/update in bin/setup, and make bin/setup idempotent)があり、その処理で使用する予定。


Simplify ActionCable.createWebSocketURL and realphabetize exports (#35810)

Action Cableの修正です。

ActionCable.createWebSocketURLに関する処理のリファクタリングとして、不要な変数を削除、exportの値をアルファベット順について修正等を行っています。


Merge pull request #35771 from timoschilling/hash-speed-improvements

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

Hash#except及び、HashWithIndifferentAccess#except#values_at#fetch_valuesRubyネイティブのメソッドを使うようリファクタリングにしています。処理高速化の為。


Merge pull request #35805 from excid3/attachments-field-generators

railtiesの修正です。

generatorにattachmentattachments fieldを指定出来るようにしています。Active Storageの設定用のfieldで、指定するとmodelへのhas_one_attached、又は、has_many_attachedの追加、formへのfield_filed等の追加を行うようになっています。


Merge pull request #24405 from waits/shallow-false

actionpack/lib/action_dispatch/routing/mapper.rbの修正です。

resourceがネストしている、かつ、親のresourceでshallwにfalseを指定していた場合、子のresourceも強制的にshallowがfalseになっていたのを子のresourceでshallowオプションを指定出来るようにしています。

resources :blogs, shallow: true do
  resources :posts do
    resources :comments, shallow: false
  end
end

というrouteがあった場合、次のように生成されるURLが変更になっています。

# before
/posts/1/comments
/comments/2

# after
/posts/1/comments
/posts/1/comments/2

Add after_save_commit callback as shortcut for after_commit :hook, on: [ :create, :update ]. (#35804)

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

commit後に処理を行うためのafter_save_commit callbackを追加しています。after_commit :hook, on: [ :create, :update ]のショートカット版。


Auto-correct rubocop offences

actionpack/test/dispatch/routing_test.rbrailties/test/application/zeitwerk_integration_test.rbの修正です。

rubocopの設定に違反している箇所があったのを修正しています。


Fixed description of the cache_key_with_version method [ci skip]

rails guideのCaching with Rails: An Overviewの修正です。

cache_key_with_versionメソッドの説明がidupdated_at attributeをベースに作成される、となっていたのを、modelのclass nameも使用される旨説明を追加しています。


Remove duplicated CHANGELOG entry [ci skip]

activerecord/CHANGELOG.mdの修正です。

重複してあったCHANGELOGのエントリーを削除しています。


Fix the markup for insert_all and upsert_all docs [ci skip]

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

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


Use official database name [ci skip]

docの修正です。

各箇所のDB名を正式名称(e.g. Postgres -> PostgreSQL)に修正しています。


Don't assign to @changed_attributes in becomes

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

becomesメソッドで使用していない@changed_attributesに値を設定していたのを、値を設定しないよう修正しています。


[ci skip] Doc for shallow: false options should use for better readability. PR after #24405

actionpack/lib/action_dispatch/routing/mapper.rbのdocの修正です。

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


bytes_margin is only needed when previous_packet exists

activerecord/lib/active_record/connection_adapters/mysql/database_statements.rbの修正です。

fixtures処理用のSQLのpacket sizeをチェックする際に、max_allowed_packetの値に対してbyte marginを加えていたのを、前のpacketに対して加えるよう修正しています。marginは前のpacketがある場合のみ考慮が必要な為。


Don't normalize original_app_name

railties/lib/rails/generators/app_name.rbの修正です。

rails newの引数のアプリ名に不正な名前が指定された場合に表示するエラーメッセージで、アプリ名が加工された状態で表示されていたのを、ユーザが指定した値がそのまま表示されるよう修正してます。


Add rake db:prepare entry to the CHANGELOG.md

activerecord/CHANGELOG.mdの修正です。

先のdb:prepare taskを追加した対応についてCHANGELOGにエントリーを追加しています。


[ci skip] Touch up db:prepare changelog entry

activerecord/CHANGELOG.mdの修正です。

db:prepare taskのエントリーの説明を修正しています。


Add test that the listen gem is included when RUBY_ENGINE is not 'ruby'

railties/test/generators/app_generator_test.rbの修正です。

listen gemがCRuby以外の環境でもGemfileに記載される事を確認するテストを追加しています。