LoginSignup
0
0

More than 1 year has passed since last update.

【備忘録】undefined method `as' for #<〜::ActiveRecord_Relation:

Posted at

Rails5.2からRails6.0への移行作業中に起きたエラー

Rails5.2時点でこんな警告が出ていました。
DEPRECATION WARNING: Delegating as to arel is deprecated and will be removed in Rails 6.0.

sql周りのメソッドでいくつか警告が出ていて、修正はしていたのですが見逃しがありました。
調べてみると

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

との記載があったため

.as('amounts')
↓↓↓
.arel.as('amounts')

このように変更。無事エラーは出なくなりました。

参考にさせていただいた記事
https://koic.hatenablog.com/entry/deprecation-warning-delegaging-arel-methods-in-rails-5-2

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0