Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 5746

Show
Ignore:
Timestamp:
12/19/06 04:41:57 (2 years ago)
Author:
rick
Message:

Ensure render :json => ... skips the layout. Closes #6808 [Josh Peek]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r5718 r5746  
    11*SVN* 
     2 
     3* Ensure render :json => ... skips the layout.  Closes #6808 [Josh Peek] 
    24 
    35* Fix HTML::Node to output double quotes instead of single quotes.  Closes #6845 [mitreandy] 
  • trunk/actionpack/lib/action_controller/layout.rb

    r5207 r5746  
    267267      def candidate_for_layout?(options) 
    268268        (options.has_key?(:layout) && options[:layout] != false) ||  
    269         options.values_at(:text, :xml, :file, :inline, :partial, :nothing).compact.empty? && 
     269        options.values_at(:text, :xml, :json, :file, :inline, :partial, :nothing).compact.empty? && 
    270270        !template_exempt_from_layout?(default_template_name(options[:action] || options[:template])) 
    271271      end 
  • trunk/actionpack/test/controller/render_test.rb

    r5695 r5746  
    4646  def render_json_hello_world_with_callback 
    4747    render_json({:hello => 'world'}.to_json, 'alert') 
     48  end 
     49 
     50  def render_symbol_json 
     51    render :json => {:hello => 'world'}.to_json 
    4852  end 
    4953 
     
    126130        when "layout_test":         "layouts/standard" 
    127131        when "builder_layout_test": "layouts/builder" 
     132        when "render_symbol_json":  "layouts/standard"  # to make sure layouts don't interfere 
    128133      end 
    129134    end 
     
    185190  end 
    186191 
     192  def test_do_with_render_symbol_json 
     193    get :render_symbol_json 
     194    assert_equal '{hello: "world"}', @response.body 
     195    assert_equal 'application/json', @response.content_type 
     196  end 
     197 
    187198  def test_do_with_render_custom_code 
    188199    get :render_custom_code