From e73f54763568f06588c227c7ca759178102b914d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 29 Apr 2012 11:16:13 +0300 Subject: Avoid calling content type multiple times --- actionpack/lib/action_controller/metal/renderers.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (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 d69816915b..4a0c1c7dd7 100644 --- a/actionpack/lib/action_controller/metal/renderers.rb +++ b/actionpack/lib/action_controller/metal/renderers.rb @@ -91,12 +91,14 @@ module ActionController add :json do |json, options| json = json.to_json(options) unless json.kind_of?(String) - unless options[:callback].blank? - json = "#{options[:callback]}(#{json})" + + if options[:callback].present? self.content_type ||= Mime::JS + "#{options[:callback]}(#{json})" + else + self.content_type ||= Mime::JSON + json end - self.content_type ||= Mime::JSON - json end add :js do |js, options| -- cgit v1.2.3