Skip to content

Commit 98ad644

Browse files
committed
Exclude _process_options options in render_json
When :callback, :content_type, or :status are also passed when caling render :json, those keys are used to control aspects of the response and aren't intended to be used for the JSON generation itself. Removing these options allows us to hit the fast path in JSON generation where we can avoid an extra deep-dup through calling .as_json.
1 parent 42d75ed commit 98ad644

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

actionpack/lib/action_controller/metal/renderers.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ def _render_to_body_with_renderer(options)
154154
end
155155

156156
add :json do |json, options|
157-
json = json.to_json(options) unless json.kind_of?(String)
157+
json_options = options.except(:callback, :content_type, :status)
158+
json = json.to_json(json_options) unless json.kind_of?(String)
158159

159160
if options[:callback].present?
160161
if media_type.nil? || media_type == Mime[:json]

0 commit comments

Comments
 (0)