Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of git@github.com:rails/rails

  • Loading branch information...
commit 6ae839bf488504cc2d3523700d5a49db1a89c76d 2 parents e59835b + f0b9e28
@jeremy jeremy authored
View
3  actionpack/lib/action_controller/base/render.rb
@@ -253,7 +253,8 @@ def render(options = nil, extra_options = {}, &block) #:doc:
response.content_type ||= Mime::JS
render_for_text(js)
- elsif json = options[:json]
+ elsif options.include?(:json)
+ json = options[:json]
json = ActiveSupport::JSON.encode(json) unless json.respond_to?(:to_str)
json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
response.content_type ||= Mime::JSON
View
10 actionpack/test/controller/render_test.rb
@@ -194,6 +194,10 @@ def accessing_controller_name_in_template
render :inline => "<%= controller_name %>"
end
+ def render_json_nil
+ render :json => nil
+ end
+
def render_json_hello_world
render :json => ActiveSupport::JSON.encode(:hello => 'world')
end
@@ -874,6 +878,12 @@ def test_render_file_from_template
assert_equal "The secret is in the sauce\n", @response.body
end
+ def test_render_json_nil
+ get :render_json_nil
+ assert_equal 'null', @response.body
+ assert_equal 'application/json', @response.content_type
+ end
+
def test_render_json
get :render_json_hello_world
assert_equal '{"hello":"world"}', @response.body
Please sign in to comment.
Something went wrong with that request. Please try again.