Skip to content

Commit

Permalink
Avoid calling content type multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Apr 29, 2012
1 parent d4dd1af commit e73f547
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions actionpack/lib/action_controller/metal/renderers.rb
Expand Up @@ -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|
Expand Down

0 comments on commit e73f547

Please sign in to comment.