Permalink
Browse files

Avoid calling content type multiple times

  • Loading branch information...
1 parent d4dd1af commit e73f54763568f06588c227c7ca759178102b914d @josevalim josevalim committed Apr 29, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 actionpack/lib/action_controller/metal/renderers.rb
@@ -91,12 +91,14 @@ module All
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|

0 comments on commit e73f547

Please sign in to comment.