なるようになるブログ

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

rails commit log流し読み(2016/03/05)

2016/03/05分のコミットです。

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


Make sure ActionCable.Subscriptions#create always returns the newly created subscription object

actioncable/app/assets/javascripts/action_cable/subscriptions.coffeeの修正です。

ActionCable.Subscriptions#createメソッドが、作成したsubscriptionのobjectを必ず返すよう修正しています。


Return subscription object(s) when updating the collection

actioncable/app/assets/javascripts/action_cable/subscriptions.coffeeの修正です。

ActionCable.Subscriptionsクラスでsubscriptionに対する処理(add / remove等)を行った際に、処理を行った後のsubscriptionの値を返すよう修正しています。


remove useless ivar

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

clear_association_scope_cacheメソッドから、使用していない変数を削除しています。


Fix author callback in engines guide [ci skip]

rails guideのGetting Started with Enginesの修正です。

Using a Model Provided by the Applicationの項で、データ保存時にassociationの設定をするexampleで、associationの設定をbefore_saveコールバックで行っていたのを、before_validationコールバックで行うよう修正しています。

Require belongs_to by default. by simi · Pull Request #18937 · rails/railsbelongs_to associationがデフォルトでrequire: trueとなった為、before_saveでassociationを設定するのだと遅い(validation処理でassociationが設定されてない事によりvalidatinoエラーになってしまう)為、before_validationで行うようにしたとの事です。


don't build the reflection chain to calculate nested?

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

#nested?メソッドでassociationがnestしているかどうかチェックする際に、reflection chainの生成処理を行わないよう修正しています。

reflection treeを横断して処理を行ってしまうのを避ける為、との事です。


We're not using $2 from this Regexp

actionview/lib/action_view/renderer/partial_renderer.rbの修正です。

PartialRenderer#retrieve_variableメソッドでpartial templateの名前のチェックをする正規表現で、使用しないグループはキャプチャしないようになっていたのですが、Fix partial rendering with dot in filename by bquorning · Pull Request #24052 · rails/railsの際に誤ってキャプチャするようにしてしまったので、再度キャプチャしないよう修正しています。


Match Puma 3 startup messages [ci skip]

rails guideの修正です。

rails serverの起動時のメッセージを表示している箇所を、最新の内容(Puma 3の出力内容)に更新しています。


start hiding the scope_chain data structure

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

scopeがあるかどうかのチェックをscope_chainを直接参照しチェックを行っていたのを、チェック用に#has_scope?メソッドを作成し、そちらを使用するよう修正しています。


remove outdated comment [ci skip]

activerecord/test/cases/validations/i18n_validation_test.rbのdocの修正です。

各テストのコメントにmochaを使っている旨記載されていたのですが、実際は使用していない(minitest/mockを使用している)為、コメントを削除しています。


Fix indentation [ci skip]

railties/test/application/rake_test.rbの出力です。

[ci skip] correcting test case specifying rails routes instead of rake routes by mohitnatoo · Pull Request #24050 · rails/rails でテスト名の変更を行った際、インデントがおかしくなってしまった為、修正しています。


remove config that are no longer needed in sprockets-rails 3

railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.ttrailties/lib/rails/generators/rails/app/templates/config/environments/production.rb.ttの修正です。

config.assets.raise_runtime_errors及びconfig.assets.digestの設定をデフォルトのconfigファイルから削除しています。sprockets-rails 3でデフォルトで有効になった為。


Remove http_cache_forever's version parameter

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

ActionController::ConditionalGet#http_cache_foreverメソッドの引数からversionを削除しています。

一度#http_cache_foreverメソッドでheaderを設定(Cache-Control: max-age=3155760000)した場合、当然browser / proxyはサーバにリクエストの取得を行わなくなり、再度取得させる為には、headerを設定し直す(Cache-Control: max-age=0)必要があります。

で、それをするにはquery parameter等を使用してresource URLを変更する必要があります。で、versionパラメータはその役割の為に、と追加されていたのですが、実際はそうは動かない(resource URLは変わらない)為、紛らわしだろう、という事で削除されたようです。


A small documentation fix about autosave associations [ci skip]

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

AutosaveAssociation moduleのdoc内のChildren recordsChild recordsに修正しています。


define APP_PATH with dir

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

APP_PATH(config/applicationのpath)を定義するのに、__FILE__を使用していたのを__dir__を使用するよう修正しています。

-APP_PATH = File.expand_path('../../config/application', __FILE__)
+APP_PATH = File.expand_path('../config/application', __dir__)

fix typo in attribute example [ci skip]

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

#attribute メソッドのexample内でkind_of?kind_ofにタイポしていたのを修正しています。