1
0

【Rails7】to_sでwrong number of arguments (given 1, expected 0) (ArgumentError)が発生する

Posted at

はじめに

Rails7にアップデート中、to_sを使用している部分でエラーが発生したので、解消方法をまとめていきます。

問題

エラー内容

date = DateTime.now
puts date.to_s(:db)

`to_s': wrong number of arguments (given 1, expected 0) (ArgumentError)

解決方法

to_sをto_fsに変更することで解消します。

date = DateTime.now
puts date.to_fs(:db)

参考

1
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
1
0