なるようになるブログ

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

rails commit log流し読み(2018/06/21)

2018/06/21分のコミットです。

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

actionview/CHANGELOG.md


add documentation for config.active_support.use_authenticated_message_encryption [ci skip]

rails guideのConfiguring Rails Applicationsの修正です。

config.active_support.use_authenticated_message_encryptionについての説明を追加しています。


Merge pull request #33175 from gsamokovarov/fix-actionpack-typo

actionpack/CHANGELOG.mdの修正です。

implicitimplictにタイポしている箇所があったのを修正しています。


Merge pull request #32190 from liwii/use_year_names

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

date_selectメソッドにyearの値をカスタマイズする為のyear_formatオプションを追加しています。

例。

date_select('user_birthday', '', start_year: 1998, end_year: 2000, year_format: -> year { "Heisei #{year - 1988}" })
<select id="user_birthday__1i" name="user_birthday[(1i)]">
<option value="1998">Heisei 10</option>
<option value="1999">Heisei 11</option>
<option value="2000">Heisei 12</option>
</select>

Update fugit to latest version

Gemfile.lockの修正です。

fugitのバージョンを最新のバージョンに更新しています。Rubyのwarningが表示されるのを避ける為。

rails commit log流し読み(2018/06/20)

2018/06/20分のコミットです。

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


Merge pull request #33074 from lsylvester/optimize-pluck

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

ActiveRecord::Result#cast_valuesで不要な一時配列を作成しないようリファクタリングしています。

ActiveRecord::Result#cast_valuesActiveRecord::Relation#pluckから呼び出される処理の為、このリファクタリングによりActiveRecord::Relation#pluck実行時に生成されるオブジェクト数が多少減少しています。


Convert hashes into parameters (#33076)

actionpack/lib/action_controller/metal/strong_parameters.rbの修正です。

ActionController::Parameters#transform_values、及び、#transform_values!メソッドでblockに渡される値がHashだったのを、ActionController::Parametersに修正しています(HashActionController::Parametersに変換してから渡すようになっています)。


Remove unused rs argument from JoinDependency#construct

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

JoinDependency#constructの引数から使用していないrsを削除しています。


Remove useless aliases argument from JoinDependency#construct

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

JoinDependency#constructの引数から使用していないaliasesを削除しています。


Remove all aliases passing from JoinDependency

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

JoinDependency#construct_modelの引数から使用していないaliasesを削除しています。

rails commit log流し読み(2018/06/19)

2018/06/19分のコミットです。

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


Add test case for the | token in Journey scanner

actionpack/test/journey/route/definition/scanner_test.rbの修正です。

Journey scannerで| tokenを指定した場合のテストを追加しています。


Fix Ruby version in .ruby-version

railties/lib/rails/generators/rails/app/templates/ruby-version.ttの修正です。

ruby-versionRubyのバージョンを指定する際に、ENV["RBENV_VERSION"]、及び、ENV["rvm_ruby_string"]の値を参照するよう修正しています。

-<%= "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}" -%>
+<%= ENV["RBENV_VERSION"] || ENV["rvm_ruby_string"] || "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}" -%>

"#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}"だと、stable version以外のversion(2.5.0.rc1jruby-9.2.0.0-SNAPSHOT)と一致しない為。


Removed useless utility classes inside HABTM association builder

activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rbの修正です。

HasAndBelongsToMany associationのbuild処理で、build処理用のユーティリティクラスを削除するようリファクタリングしています。


Merge pull request #33134 from dasch/dasch/extra-cache-controls

actionpack/lib/action_controller/metal/conditional_get.rbactionpack/lib/action_dispatch/http/cache.rbの修正です。

expires_inメソッドに、stale-while-revalidate、及び、stale-if-error Extensionのサポートを追加しています。

オプションにstale_while_revalidatestale_if_errorオプションが指定出来るようになっており、指定した値がそのままCache-Control ヘッダーに含まれるようになっています。

参考:RFC 5861 - HTTP Cache-Control Extensions for Stale Content


Ensure to calculate column aliases after all table aliases are constructed

Active Recordの修正です。

すべてのtable aliases の構築が終わった後にcolumn aliasesの生成を行うよう修正しています。

元々は、FROM句ですべてのtable aliasesの作成する前に、eager loadingに使用されるcolumn aliasesの生成が行われていました。

ただそれだと、joinとeager loadingの両方に同じテーブルのassociatonが指定された場合に、column aliasesとtable aliasesでaliasの値が一致しなくなるケースが発生してしまっていました。

で、その問題に対応する為、column aliasesの生成をすべてのtable aliasesの構築後に行うようにしています。

rails commit log流し読み(2018/06/18)

2018/06/18分のコミットです。

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

activerecord/CHANGELOG.md


Remove unused require

railties/lib/rails/commands/server/server_command.rbの修正です。

使用していないrequireを削除しています。


Add docs for ActiveRecord::Migration#say, #say_with_time, #suppress_messages [ci skip]

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

ActiveRecord::Migration#say#say_with_timesuppress_messagesメソッドにdocを追加しています。


Fix touch option to behave consistently with Persistence#touch method

Active Recordの修正中です。

increment!update_countersメソッドで、touchオプションにattribute namesを指定した場合に、その指定されたattributes namesだけ更新されて、update_at/onは更新されていなかったのを、update_at/on も更新する(指定されたattributes names + update_at/on が更新される)ように修正しています。

Persistence#touchと挙動を合わせる為。

rails commit log流し読み(2018/06/17)

2018/06/17分のコミットです。

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


Fix "warning: Net::HTTPResponse#header is obsolete"

activestorage/test/service/gcs_service_test.rbの修正です。

obsoleteになっているNet::HTTPResponse#headerメソッドを使っている箇所があったのを修正しています。

rails commit log流し読み(2018/06/16)

2018/06/16分のコミットです。

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


Fix Active Storage configuration example [ci skip]

rails guideのConfiguring Rails Applicationsの修行です。

Configuring Active Storageの項、config.active_storage.queue、及び、config.active_storage.loggerに値を指定するexampleでkey名が誤っていたのを修正しています。

rails commit log流し読み(2018/06/15)

2018/06/15分のコミットです。

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


Update example for whitelisting arbitrary hashes

rails guideのAction Controller Overviewの修正です。

Strong Parametersで任意のHashのpermitは出来ない(必ずkeyを明示する必要がある)旨説明されている箇所があったのですが、Rails 5.1以降は出来る(adds support for arbitrary hashes in strong parameters)ようになっているので、その旨説明を修正しています。


Fix rubocop violations

actionpack/test/controller/test_case_test.rbの修正です。

テスト内でrubocopの規約に違反している箇所があったのを修正しています