Skip to content

Commit 8baed8c

Browse files
committed
Fix active model tests
1 parent 6b5fe5f commit 8baed8c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

activesupport/lib/active_support/json/as_json_encoder.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ def encode(object)
2222
if AsJSONEncoder.internal_as_json?(object)
2323
visit object
2424
else
25-
encode object.as_json
25+
# **ONLY** top level objects implementing as_json should
26+
# get the options hash
27+
if !@as_json_options.nil?
28+
self.class.new(nil).encode object.as_json(@as_json_options.dup)
29+
else
30+
self.class.new(nil).encode object.as_json
31+
end
2632
end
2733
end
2834

0 commit comments

Comments
 (0)