0
0

【Rails】delete_allでエラーが発生する

Posted at

はじめに

Railsのアップデート中にdelete_allを使用している箇所でエラーが出たので、その対応をまとめます。

問題

コード

User.delete_all(company_id: company.id)

エラー文

wrong number of arguments (given 1, expected 0)

解決方法

Rails7では、delete_allに引数を取れなくなっているので、whereを使用するように修正します。

User.where(company_id: company.id).delete_all

参考

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