なるようになるブログ

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

rails commit log流し読み(2017/05/27)

2017/05/27分のコミットです。

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

activesupport/CHANGELOG.md


Merge pull request #29232 from koic/ci_against_jruby_9_1_10_0

.travis.ymlの修正です。

CIで使用するJRubyのバージョンを9.1.10.0に更新しています。


Remove a redundant test assertion

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

findメソッドのテストで重複したassertionがあったのを削除しています。


ActiveSupport::CurrentAttributes provides a thread-isolated attributes singleton (#29180)

スレッド毎に独立したattibutesを管理するためのActiveSupport::CurrentAttributesクラスを追加しています。リクエスト毎のattribute(リクエストIDやUA等)をシステム全体で使用可能にする、のが主なユースケースとの事です。リクエストの前後で自動でattributeのresetが行われるよう対応されています。

具体的な使い方はDoc(ActiveSupport::CurrentAttributes)参照。


Doc updates for ActiveRecord::Batches

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

ActiveRecord::Batches moduleのdoc内のexampleコードが動作しないコードになっていたのを修正、及び、doc内のフォーマットの修正を行っています。


Merge pull request #25037 from mohitnatoo/adapter-inquirer

activejob/lib/active_job/queue_adapter.rbの修正です。

QueueAdapter moduleにqueue_adapter_nameメソッドを追加しています。

class Job1 < ApplicationJob
  self.queue_adapter = :resque
end

> Job1.queue_adapter_name
#=> "resque"

Fix broken RDoc formatting

activemodel/lib/active_model/validator.rbのdocの修正です。

ActiveModel::Validatorクラスのdocでoptions[:class]がタイプライター体で表示されるよう、ttタグで囲むよう修正しています。


Update to rails-ujs documentation for yarn install

actionview/app/assets/javascripts/README.mdの修正です。

rails-ujisをnpm経由でインストールした場合の使い方についての説明を追加しています。


Switch to rb-inotify master

Gemfileの修正です。

rb-inotify gemを使用するのにforkしたリポジトリを使用していたのを、rb-inotifyのmasterリポジトリを指定するよう修正しています。forkしたブランチのPRがmasterにマージされた為。


[ci skip]fix wrong variable name in docs

rails guideのActive Record Query Interfaceの修正です。

Arrayを格納する変数の変数名が単数形になっていたのを複数形に修正しています。


[ci skip]fix wrong variable name in docs

rails guideのActive Record Query Interfaceの修正です。

Arrayを格納する変数の変数名が単数形になっていたのを複数形に修正しています。


Use models to match the docs.

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

ActiveSupport::CurrentAttributesのテストで、テスト用クラスを定義するファイルをapp/services/current.rbからapp/models/current.rbに修正しています。docに記載されているexampleコードと合わせる為。


[ci skip] Fix spelling that’s a bit of an overreach.

activesupport/lib/active_support/current_attributes.rbのdocの修正です。

ActiveSupport::CurrentAttributesの docのグラマーの修正を行っています


Use non-raising finder.

ActiveSupport::CurrentAttributesの doc内のexampleコードで、userの取得にfindを使用していたのをfind_byを使用するよう修正しています。

-  #         if authenticated_user = User.find(cookies.signed[:user_id])
+  #         if authenticated_user = User.find_by(id: cookies.signed[:user_id])
   #           Current.user = authenticated_user
   #         else
   #           redirect_to new_session_url

findを使ってしまうと、userが見つからなかった場合にexceptionがraiseされてしまい、elseの処理が実行されない為。