From b00b638b95dc513f4ba854ba3a96b7a8f344e4cc Mon Sep 17 00:00:00 2001 From: Lucas Mazza Date: Wed, 2 Jul 2014 18:48:04 -0300 Subject: Change the JSON renderer to enforce the 'JS' Content Type The controller can set the response format as 'JSON' before the renderer code be evaluated, so we must replace it when necessary. Fixes #15081 --- actionpack/lib/action_controller/metal/renderers.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/metal/renderers.rb b/actionpack/lib/action_controller/metal/renderers.rb index 46405cef55..ae55e6d7f5 100644 --- a/actionpack/lib/action_controller/metal/renderers.rb +++ b/actionpack/lib/action_controller/metal/renderers.rb @@ -112,7 +112,10 @@ module ActionController json = json.to_json(options) unless json.kind_of?(String) if options[:callback].present? - self.content_type ||= Mime::JS + if self.content_type.nil? || self.content_type == Mime::JSON + self.content_type = Mime::JS + end + "#{options[:callback]}(#{json})" else self.content_type ||= Mime::JSON -- cgit v1.2.3