Internal server error 500 while going through guide

When I was going through this guide ( Getting Started with Rails — Ruby on Rails Guides at this point Getting Started with Rails — Ruby on Rails Guides ) this error happened. I’ve just placed the string (root “products#index”) and the error.

# config/routes.rb
Rails.application.routes.draw do
  # ...
  root "products#index"
  resources :products
end

Could anyone help me and say why and how can I fix this?

Ruby 4.0.6 (asdf), Rails 8.1.3.1, OS Ubuntu 26.04

From development.log:

Started GET "/products" for ::1 at 2026-09-08 22:25:11 +0200

Processing by ProductsController#index as HTML

  Rendering layout layouts/application.html.erb

  Rendering products/index.html.erb within layouts/application

  Product Load (0.1ms)  SELECT "products".* FROM "products" /*action='index',application='Store',controller='products'*/

  ↳ app/views/products/index.html.erb:4

  Rendered products/index.html.erb within layouts/application (Duration: 1.8ms | GC: 0.0ms)

  Rendered layout layouts/application.html.erb (Duration: 2.6ms | GC: 0.0ms)

Completed 500 Internal Server Error in 4ms (ActiveRecord: 0.1ms (1 query, 0 cached) | GC: 0.0ms)





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

Caused by: ArgumentError (wrong number of arguments (given 2, expected 1))




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

7:     <meta name="application-name" content="Store">

8:     <meta name="mobile-web-app-capable" content="yes">

9:     <%= csrf_meta_tags %>

10:     <%= csp_meta_tag %>

11: 

12:     <%= yield :head %>

13: 

app/views/layouts/application.html.erb:10




Information for cause: ArgumentError (wrong number of arguments (given 2, expected 1)):

app/views/layouts/application.html.erb:10

Started GET "/favicon.ico" for ::1 at 2026-09-08 22:25:11 +0200

ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
1 Like

O ya — I have seen this as of the past couple of days. It’s due to this update in the json gem.

Reason is that in active_support it tries to call ::JSON.parse with two parameters — the JSON payload and options. Meanwhile a couple days back that method signature changed so that those options come in as the “keyrest” part of the parameters (i.e. the rest of any keyword parameters aside from the ones specifically called out, which are on_load, object_class, and array_class).

Try putting this into your Gemfile, then bundle, and see if everything is happy:

gem 'json', '< 3.0.2'

This has already been fixed in rails master, but not yet back-ported to Rails 8.1.x.

1 Like

This doesn’t help. I put gem 'json', '< 3.0.2' at the bottom of Gemfile. Ran bundle install. The same thing. An error on the page http://localhost:3000/products and working localhost:3000 while removing root “products#index”.

2 Likes

Well now I’m curious!

Feel free to either create a Github repository of the code you’re using, or zip it up and send it to lorint@gmail.com.

Curious to figure out what is happening.

Hi Lorin, i have the same trouble and this not solve that.

I’m running Rails 8.1.3.1, ruby ruby 4.0.6 (2026-07-14 revision 03b6d3f889) +PRISM [arm64-darwin25].

I just created the app with ‘rails new App -d postgresql’, and when I added the first route ‘get ’/products’, to: ‘products#index’, it started failing—every time I make a change, I get a 500 error. After every change, I have to open an incognito window to check it, and when I make another change, I get a 500 error again. I have to close that window, open a new one, and then I can check the new change. I’ve already installed JSON 3.0.2, and it’s still the same.

I have the same error and behaviour.

Rails 8.1.3.1
ruby 4.0.6 (2026-07-14 revision 03b6d3f889) +PRISM \[x86_64-linux\]
$ ./bin/rails c
Loading development environment (Rails 8.1.3.1)
blog(dev):001> JSON::VERSION
=> "3.0.1"

Some additional info. I’ve noticed that a 500 error appears only when rails sets up a session cookie in the browser. After I manually cleared the session cookie, the page loads ok, but after the browser refresh I’ve got a 500 error.

To reproduce

$ rails new blog
$ cd blog
$ ./bin/rails g scaffold post title content
$ ./bin/rails db:migrate

and point the browser to http://localhost:3000/posts. First load is ok, then a 500 error.

1 Like

I figured it out—as Lorin said, it’s a compatibility issue with version 3.x.x of JSON. Just change it in the Gemfile to (gem ‘json’, ‘< 2.10’) and run bundle update json.

You have to get this :down_arrow:

2 Likes

Thanks! Can confirm that!

The line in Gemfile should probably be

gem "json", "< 3.0.0"
3 Likes

Thanks @estebanvsx and @tba81 — Teamwork makes the dream work!

p.s. - for anyone wanting to use the newer JSON gem then here’s a monkey patch to smarten up the newer JSON#parse method so that it will work with both Rails < 8.2 and edge Rails:

# Monkey patch to allow Rails < 8.2 to work with json gem >= 3.0
require 'json'
if ::JSON.method(:parse).parameters.select { |p| [ :req, :opt ].include?(p.first) }.length < 2
  ::JSON.module_exec do
    # This "define_singleton_method" trick is the same general idea as aliasing in this way:
    #   alias_method :_orig_parse, :parse
    # but works in a module instead of a class.
    define_singleton_method(:_orig_parse, singleton_method(:parse))
    module_function
    def parse(source, options_param = nil, **options)
      options.merge!(options_param) if options_param
      _orig_parse(source, **options)
    end
  end
end

If you put this at the end of your boot.rb file then it will allow JSON v3.02 to work.

2 Likes

Thank you, guys! I worked for me. Now I can continue to learn Rails.)

2 Likes

It works with me. Put it at the very top. Then bundle install.

1 Like

It looks like the issue may be with how the root route was added. In Rails, it should be written inside config/routes.rb like this:

Rails.application.routes.draw do
  root "products#index"
end

Also, make sure the ProductsController has an index action and that the corresponding view exists. If you’re still getting the error, please share the exact error message and your config/routes.rb file so others can identify the issue.