-
-
Notifications
You must be signed in to change notification settings - Fork 260
#as_json ignored on Rails 7.2.0 #934
Copy link
Copy link
Closed
Description
Reading through the other issues, I'm sorry to break the news, but it looks like your favorite issue with #to_json and #as_json is back with the recent release of Rails 7.2.0. The issue doesn't show up with Rails 7.1.x, but looking through the Rails source code it isn't immediately apparent what changed.
The issue shows up upon calling Oj.mimic_JSON. Adding or removing Oj.optimize_rails, doesn't change the behavior.
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'rails', '7.2.0' # No issues with 7.1.0
gem 'oj', '3.16.5'
end
Oj.mimic_JSON # This seems to cause the issue
Oj.optimize_rails # Does not have an effect on the issue
class TestObject
def as_json
{ foo: :bar }
end
end
puts TestObject.new.to_jsonExpected output:
{"foo":"bar"}
Actual output:
"#<Test:0x000000012024e9d0>"
Thanks a lot for this gem! I've been using it without any problems for years now 💛
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels