Internal server error 500 while going through guide

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