Rails 5.2でActive RecordからArelのメソッドへの移譲に追加されている非推奨警告

Rails 5.2.1 アプリケーションの 24 Pull Requests へのパッチを元にした昨年末の日記の関連。

以下のような警告の川が流れた際には、.arel をレシーバーとして明示的に指定する。

DEPRECATION WARNING: Delegating exists to arel is deprecated and will be
removed in Rails 6.0.
DEPRECATION WARNING: Delegating with to arel is deprecated and will be
removed in Rails 6.0.

24 Pull Requests へのパッチを例にすると以下のような変更になる。

   def self.pull_request_filter
     where("pull_requests.user_id = aggregation_filters.user_id")
     .where("pull_requests.title ILIKE aggregation_filters.title_pattern")
+    .exists.not
-    .arel.exists.not
   end
- it { expect(assigns(:users).with(User.order('pull_requests_count desc').page(0))).to be_truthy }
+ it { expect(assigns(:users).arel.with(User.order('pull_requests_count desc').page(0))).to be_truthy }

導入経緯や対象となるメソッドなどは、この警告が導入された PR に詳しい。

github.com