diff options
author | José Valim <jose.valim@gmail.com> | 2012-04-29 11:16:13 +0300 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-04-29 11:16:13 +0300 |
commit | e73f54763568f06588c227c7ca759178102b914d (patch) | |
tree | d17ac26c78414e5f0bd2f6d847f97005acbc49c8 /actionpack | |
parent | d4dd1af341dcc1908b594567991845324df0ee56 (diff) | |
download | rails-e73f54763568f06588c227c7ca759178102b914d.tar.gz rails-e73f54763568f06588c227c7ca759178102b914d.tar.bz2 rails-e73f54763568f06588c227c7ca759178102b914d.zip |
Avoid calling content type multiple times
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/metal/renderers.rb | 10 |
1 files changed, 6 insertions, 4 deletions
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| |