なるようになるブログ

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

rails commit log流し読み(2022/09/07)

2022/09/07分のコミットです。

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

actiontext/CHANGELOG.md


Merge pull request #45739 from basecamp/content-attachment-update

Action Textの修正です。

Action Textのtagのcontent attributeに任意のHTMLの値を指定出来るように修正しています。指定されたHTMLはtagのrender時にelementの本文として表示されるようになっています。


Improve word_wrap performance

actionview/lib/action_view/helpers/text_helper.rbの修正です。

word_wrapメソッドについて、オブジェクト生成数を減らすようリファクタリングしています。


View path strict type casting

actionview/lib/action_view/lookup_context.rbactionview/lib/action_view/path_set.rbの修正です。

PathSetのtype cast処理で、不正な値が指定された場合エラーとするよう修正しています。


Update redis and resque

Active Jobのテスト、Gemfileの修正です。

redisresqueのバージョンを最新バージョンに更新、及び、Active Jobのテストがredis 5系で通るよう修正しています。

rails commit log流し読み(2022/09/06)

2022/09/06分のコミットです。

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

actionview/CHANGELOG.md


Remove obsolete word_wrap test

actionview/test/template/text_helper_test.rbの修正です。

word_wrapの引数の値が変更されていない事を確認するテストを削除しています。現在引数の指定はキーワード引数になっており、引数の変更は出来なくなっている為。


Chomp the break_sequence in word_wrap

actionview/lib/action_view/helpers/text_helper.rbの修正です。

word_wrapbreak_sequenceオプションにprintable charactersが含まれている場合に、break_sequenceの削除がされないバグがあったのを修正しています。

# <%= word_wrap("11 22\n33 44", line_width: 2, break_sequence: "\n# ") %>

Before:

# 11
# 22
#
# 33
# 44
#

After:

# 11
# 22
# 33
# 44

Expand word_wrap test coverage

actionview/test/template/text_helper_test.rbの修正です。

word_wrapメソッドのテストを追加しています。


Clarify description of --force-plural option

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

--force-pluralオプションのdescriptionをより適切な内容に修正しています。


Clarify description of --api option

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

--api optionのdescriptionを追加しています。

rails commit log流し読み(2022/09/03)

2022/09/03分のコミットです。

CHANGELOGへの追加はありませんでした。


Speed up arel visitor dispatch

activerecord/lib/arel/visitors/visitor.rbの修正です。

Arel::Visitors::Visitorで行っているdispatch処理について、性能改善のリファクタリングを行っています。

rails commit log流し読み(2022/09/02)

2022/09/02分のコミットです。

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

activesupport/CHANGELOG.md

activerecord/CHANGELOG.md


Update stackprof

Gemfile.lockの修正です。

stackprof gemを最新バージョンに更新しています。


Avoid using Module#<= in value_for

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

value_forメソッドでscope typeを取得するのにModule#<=を使用しないようリファクタリングしています。性能改善対応。


Support thread_mattr_accessor in anonymous classes

activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rbの修正です。

anonymous classでthread_mattr_accessorを使用出来るよう修正しています。


Formatting typo

rails guideのActive Record Validationsの修正です。

ページ内リンクが動作するようdocのフォーマットの修正を行っています。


Merge pull request #45917 from jonathanhefner/redirect_action_dispatch-payload-include-request

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

redirect.action_dispatch payloadにrequestオブジェクトを追加しています。redirect_to.action_controllerと同じpayloadになるようにする為。


Freeze thread_mattr_accessor default values

activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rbの修正です。

thread_mattr_accessordefault valueをfreezeするよう修正しています。複数のスレッドでアクセスする値のため、動的に変更されてしまうのを防ぐため。


Avoid using render(...) and return in example code

actionpack/lib/abstract_controller/rendering.rbrails guideのLayouts and Rendering in Railsの修正です。

doc及びDoubleRenderError classで使用するエラーメッセージで、renderやredirectするのにxx and returnという処理(e.g. redirect_to(...) and return)があったのを、andを使わない(複数行で只のreturnを使用)に修正しています。初心者が見た時にわかりづらいコードであり、避けた方が良いだろう、という事で修正されています。


Merge pull request #45923 from compeak/main

activestorage/db/migrate/20170806125915_create_active_storage_tables.rbの修正です。

Active Storageが生成するmigrationファイルのRailsのバージョンを7.0に更新しています。


Merge pull request #45911 from fatkodima/invalid-range-disk-controller

activestorage/app/controllers/concerns/active_storage/file_server.rbの修正です。

partial downloadに不正なRangeを指定した場合に、responseのHTTP statusが404になってしまっていたのを、416(Range Not Satisfiable)になるよう修正しています。


Add missing documentation for Rails.error

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

Rails.errorにdocを追加しています。


Allow AR::QueryMethods#select to accept a hash

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

ActiveRecord::QueryMethods#selectにtable名 + columnsまたはaliasesをHashで指定出来るよう修正しています。

Post.joins(:comments).select(posts: [:id, :title, :created_at], comments: [:id, :body, :author_id])
#=> "SELECT \"posts\".\"id\", \"posts\".\"title\", \"posts\".\"created_at\", \"comments\".\"id\", \"comments\".\"body\", \"comments\".\"author_id\"
#   FROM \"posts\" INNER JOIN \"comments\" ON \"comments\".\"post_id\" = \"posts\".\"id\""

Post.joins(:comments).select(posts: { id: :post_id, title: :post_title }, comments: { id: :comment_id, body: :comment_body })
#=> "SELECT posts.id as post_id, posts.title as post_title, comments.id as comment_id, comments.body as comment_body
#    FROM \"posts\" INNER JOIN \"comments\" ON \"comments\".\"post_id\" = \"posts\".\"id\""

Fix ActiveRecord::FinderMethods.find when passing multiple ids and primary key is not selected

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

ActiveRecord::FinderMethods.findに複数idを指定 + primary keyが未指定の場合に結果が取得出来ないバグがあったのを修正しています。


Do not mutate relation when implicitly selecting a primary key in ActiveRecord.find

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

先のfindの修正で暗黙的にRelationの状態を変更していた(primary keyを設定していた)のを、Relationの状態は変更しないよう修正しています。