0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

json を 3.0 に上げたら Rails が死んだ

0
Last updated at Posted at 2026-09-09

2026年9月7日に json gem の 3.0.0 がリリースされた。
それにアップデートしたら Rails アプリが死んだ。
(記事執筆時点で json の最新版は 3.0.2 だが,状況は同じ)

再現手順

Rails 8.1.3.1 で

rails new testapp
cd testapp
rails g scaffold item name
rails db:migrate
bin/dev

これで http://localhost:3000/items/ にアクセスする。
そしてリロードすると 500 Internal Server Error になる。
初回だけなぜかエラーにならず,2 回目以降がエラーになる。

app/views/items/index.html.erb で

ActionView::Template::Error (wrong number of arguments (given 2, expected 1))

が出るのだが,直接にはどこが問題なのか分からない。
見える範囲には JSON を使ったコードは無い。

解決

rails 側で issue が提出されており,修正も既に行われている。
After update gem json to 3.0.0 Rails 8.1.3.1 raise the error: wrong number of arguments (given 2, expected 1) · Issue #58685 · rails/rails

修正版がいつリリースされるのかは分からない。

参考

先日こんな記事を書いた:
【Ruby】json を 3.0.0 にしたら cairo が死んだ - Qiita

追記 2026-09-12

本件に関して参考になる記事が出た:

Railsで「curlは200、ブラウザは500」になった原因はjson gem 3系との互換性だった - Qiita

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?