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

Ticket #8900: remove_deprecated_render_methods.patch

File remove_deprecated_render_methods.patch, 36.2 kB (added by lifofifo, 2 years ago)

Also remove deprecated render methods

  • actionpack/test/controller/render_test.rb

    old new  
    1919  end 
    2020 
    2121  def render_hello_world 
    22     render "test/hello_world" 
     22    render :template => "test/hello_world" 
    2323  end 
    2424 
    2525  def render_hello_world_from_variable 
    2626    @person = "david" 
    27     render_text "hello #{@person}" 
     27    render :text => "hello #{@person}" 
    2828  end 
    2929 
    3030  def render_action_hello_world 
    31     render_action "hello_world" 
     31    render :action => "hello_world" 
    3232  end 
    3333 
    3434  def render_action_hello_world_with_symbol 
    35     render_action :hello_world 
     35    render :action => :hello_world 
    3636  end 
    3737 
    3838  def render_text_hello_world 
    39     render_text "hello world" 
     39    render :text => "hello world" 
    4040  end 
    4141 
    4242  def render_json_hello_world 
    43     render_json({:hello => 'world'}.to_json) 
     43    render :json => {:hello => 'world'}.to_json 
    4444  end 
    4545 
    4646  def render_json_hello_world_with_callback 
    47     render_json({:hello => 'world'}.to_json, 'alert') 
     47    render :json => {:hello => 'world'}.to_json, :callback => 'alert' 
    4848  end 
    4949 
    5050  def render_symbol_json 
     
    5252  end 
    5353 
    5454  def render_custom_code 
    55     render_text "hello world", "404 Moved" 
     55    render :text => "hello world", :status => 404 
    5656  end 
    5757 
    58   def render_text_appendix 
    59     render_text "hello world" 
    60     render_text ", goodbye!", "404 Not Found", true 
    61   end 
    62  
    6358  def render_nothing_with_appendix 
    64     render_text "appended", nil, true 
     59    render :text => "appended" 
    6560  end 
     61   
     62  def render_invalid_action 
     63    render_action "hello_world" 
     64  end 
     65   
     66  def render_invalid_text 
     67    render_text "hello_world" 
     68  end 
     69   
     70  def render_invalid_json 
     71    render_json({:hello => 'world'}.to_json) 
     72  end 
     73   
     74  def render_invalid_xml 
     75    render_json({:hello => 'world'}.to_xml) 
     76  end 
     77   
     78  def render_invalid_args 
     79    render("test/hello") 
     80  end 
    6681 
    6782  def render_xml_hello 
    6883    @name = "David" 
    69     render "test/hello" 
     84    render :template => "test/hello" 
    7085  end 
    7186 
    7287  def heading 
     
    7893  end 
    7994 
    8095  def layout_test 
    81     render_action "hello_world" 
     96    render :action => "hello_world" 
    8297  end 
    8398 
    8499  def builder_layout_test 
    85     render_action "hello" 
     100    render :action => "hello" 
    86101  end 
    87102 
    88103  def builder_partial_test 
    89     render_action "hello_world_container" 
     104    render :action => "hello_world_container" 
    90105  end 
    91106 
    92107  def partials_list 
    93108    @test_unchanged = 'hello' 
    94109    @customers = [ Customer.new("david"), Customer.new("mary") ] 
    95     render_action "list" 
     110    render :action => "list" 
    96111  end 
    97112 
    98113  def partial_only 
    99     render_partial 
     114    render :partial => true 
    100115  end 
    101116 
    102117  def hello_in_a_string 
    103118    @customers = [ Customer.new("david"), Customer.new("mary") ] 
    104     render_text "How's there? #{render_to_string("test/list")}" 
     119    render :text => "How's there? " + render_to_string(:template => "test/list") 
    105120  end 
    106121 
    107122  def accessing_params_in_template 
    108     render_template "Hello: <%= params[:name] %>" 
     123    render :inline => "Hello: <%= params[:name] %>" 
    109124  end 
    110125 
    111126  def accessing_local_assigns_in_inline_template 
     
    187202  end 
    188203 
    189204  def test_do_with_render 
    190     assert_deprecated_render { get :render_hello_world } 
     205    get :render_hello_world 
    191206    assert_template "test/hello_world" 
    192207  end 
    193208 
     
    232247  def test_do_with_render_custom_code 
    233248    get :render_custom_code 
    234249    assert_response 404 
     250    assert_equal 'hello world', @response.body 
    235251  end 
    236252 
    237   def test_do_with_render_text_appendix 
    238     get :render_text_appendix 
    239     assert_response 404 
    240     assert_equal 'hello world, goodbye!', @response.body 
    241   end 
    242  
    243253  def test_do_with_render_nothing_with_appendix 
    244254    get :render_nothing_with_appendix 
    245255    assert_response 200 
    246256    assert_equal 'appended', @response.body 
    247257  end 
    248  
     258   
     259  def test_attempt_to_render_invalid_action 
     260    assert_raises(NoMethodError) { get :render_invalid_action } 
     261  end 
     262   
     263  def test_attempt_to_render_invalid_text 
     264    assert_raises(NoMethodError) { get :render_invalid_text } 
     265  end 
     266   
     267  def test_attempt_to_render_invalid_json 
     268    assert_raises(NoMethodError) { get :render_invalid_json } 
     269  end 
     270   
     271  def test_attempt_to_render_invalid_xml 
     272    assert_raises(NoMethodError) { get :render_invalid_xml } 
     273  end 
     274   
     275  def test_attempt_to_render_with_invalid_arguments 
     276    assert_raises(ActionController::RenderError) { get :render_invalid_args } 
     277  end 
     278   
    249279  def test_attempt_to_access_object_method 
    250280    assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { get :clone } 
    251281  end 
     
    255285  end 
    256286 
    257287  def test_render_xml 
    258     assert_deprecated_render { get :render_xml_hello } 
     288    get :render_xml_hello 
    259289    assert_equal "<html>\n  <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body 
    260290  end 
    261291 
     
    418448  end 
    419449 
    420450  protected 
    421     def assert_deprecated_render(&block) 
    422       assert_deprecated(/render/, &block) 
    423     end 
    424  
     451   
    425452    def etag_for(text) 
    426453      %("#{Digest::MD5.hexdigest(text)}") 
    427454    end 
  • actionpack/test/controller/action_pack_assertions_test.rb

    old new  
    77  def nothing() head :ok end 
    88 
    99  # a standard template 
    10   def hello_world() render "test/hello_world"; end 
     10  def hello_world() render :template => "test/hello_world"; end 
    1111 
    1212  # a standard template 
    13   def hello_xml_world() render "test/hello_xml_world"; end 
     13  def hello_xml_world() render :template => "test/hello_xml_world"; end 
    1414 
    1515  # a redirect to an internal location 
    1616  def redirect_internal() redirect_to "/nothing"; end 
     
    3838  # putting stuff in the flash 
    3939  def flash_me 
    4040    flash['hello'] = 'my name is inigo montoya...' 
    41     render_text "Inconceivable!" 
     41    render :text => "Inconceivable!" 
    4242  end 
    4343 
    4444  # we have a flash, but nothing is in it 
    4545  def flash_me_naked 
    4646    flash.clear 
    47     render_text "wow!" 
     47    render :text => "wow!" 
    4848  end 
    4949 
    5050  # assign some template instance variables 
     
    5454  end 
    5555 
    5656  def render_based_on_parameters 
    57     render_text "Mr. #{params[:name]}" 
     57    render :text => "Mr. #{params[:name]}" 
    5858  end 
    5959 
    6060  def render_url 
    61     render_text "<div>#{url_for(:action => 'flash_me', :only_path => true)}</div>" 
     61    render :text => "<div>#{url_for(:action => 'flash_me', :only_path => true)}</div>" 
    6262  end 
    6363 
    6464  def render_text_with_custom_content_type 
     
    6868  # puts something in the session 
    6969  def session_stuffing 
    7070    session['xmas'] = 'turkey' 
    71     render_text "ho ho ho" 
     71    render :text => "ho ho ho" 
    7272  end 
    7373 
    7474  # raises exception on get requests 
    7575  def raise_on_get 
    7676    raise "get" if request.get? 
    77     render_text "request method: #{request.env['REQUEST_METHOD']}" 
     77    render :text => "request method: #{request.env['REQUEST_METHOD']}" 
    7878  end 
    7979 
    8080  # raises exception on post requests 
    8181  def raise_on_post 
    8282    raise "post" if request.post? 
    83     render_text "request method: #{request.env['REQUEST_METHOD']}" 
     83    render :text => "request method: #{request.env['REQUEST_METHOD']}" 
    8484  end 
    8585 
    8686  def get_valid_record 
     
    310310    process :nothing 
    311311    assert !@response.rendered_with_file? 
    312312 
    313     assert_deprecated(/render/) { process :hello_world } 
     313    process :hello_world 
    314314    assert @response.rendered_with_file? 
    315315    assert 'hello_world', @response.rendered_file 
    316316  end 
     
    461461  end 
    462462 
    463463  def test_rendering_xml_sets_content_type 
    464     assert_deprecated(/render/) { process :hello_xml_world } 
     464    process :hello_xml_world 
    465465    assert_equal('application/xml; charset=utf-8', @response.headers['type']) 
    466466  end 
    467467 
    468468  def test_rendering_xml_respects_content_type 
    469469    @response.headers['type'] = 'application/pdf' 
    470     assert_deprecated(/render/) { process :hello_xml_world } 
     470    process :hello_xml_world 
    471471    assert_equal('application/pdf; charset=utf-8', @response.headers['type']) 
    472472  end 
    473473 
  • actionpack/test/controller/new_render_test.rb

    old new  
    157157  def partial_with_hash_object 
    158158    render :partial => "hash_object", :object => {:first_name => "Sam"} 
    159159  end 
    160  
     160   
     161  def partial_hash_collection 
     162    render :partial => "hash_object", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ] 
     163  end 
     164   
     165  def partial_hash_collection_with_locals 
     166    render :partial => "hash_greeting", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ], :locals => { :greeting => "Hola" } 
     167  end 
     168   
    161169  def partial_with_implicit_local_assignment 
    162170    @customer = Customer.new("Marcel") 
    163171    render :partial => "customer" 
     
    169177   
    170178  def hello_in_a_string 
    171179    @customers = [ Customer.new("david"), Customer.new("mary") ] 
    172     render :text =>  "How's there? #{render_to_string("test/list")}" 
     180    render :text =>  "How's there? " << render_to_string(:template => "test/list") 
    173181  end 
    174182   
    175183  def render_to_string_with_assigns 
     
    208216  end 
    209217 
    210218  def render_with_explicit_template 
    211     render "test/hello_world" 
     219    render :template => "test/hello_world" 
    212220  end 
    213221 
    214222  def double_render 
     
    619627  end 
    620628 
    621629  def test_render_with_explicit_template 
    622     assert_deprecated(/render/) { get :render_with_explicit_template } 
     630    get :render_with_explicit_template 
    623631    assert_response :success 
    624632  end 
    625633 
     
    680688    get :partial_with_hash_object 
    681689    assert_equal "Sam", @response.body 
    682690  end 
     691   
     692  def test_hash_partial_collection 
     693    get :partial_hash_collection 
     694    assert_equal "PratikAmy", @response.body 
     695  end 
     696   
     697  def test_partial_hash_collection_with_locals 
     698    get :partial_hash_collection_with_locals 
     699    assert_equal "Hola: PratikHola: Amy", @response.body 
     700  end 
    683701 
    684702  def test_partial_with_implicit_local_assignment 
    685703    get :partial_with_implicit_local_assignment 
  • actionpack/test/controller/session_management_test.rb

    old new  
    55    session :off 
    66 
    77    def show 
    8       render_text "done" 
     8      render :text => "done" 
    99    end 
    1010 
    1111    def tell 
    12       render_text "done" 
     12      render :text => "done" 
    1313    end 
    1414  end 
    1515 
     
    2020            :if => Proc.new { |r| r.parameters[:ws] } 
    2121 
    2222    def show 
    23       render_text "done" 
     23      render :text => "done" 
    2424    end 
    2525 
    2626    def tell 
    27       render_text "done" 
     27      render :text => "done" 
    2828    end 
    2929 
    3030    def conditional 
    31       render_text ">>>#{params[:ws]}<<<" 
     31      render :text => ">>>#{params[:ws]}<<<" 
    3232    end 
    3333  end 
    3434 
     
    3636    session :disabled => false, :only => :something 
    3737 
    3838    def something 
    39       render_text "done" 
     39      render :text => "done" 
    4040    end 
    4141 
    4242    def another 
    43       render_text "done" 
     43      render :text => "done" 
    4444    end 
    4545  end 
    4646 
  • actionpack/test/controller/components_test.rb

    old new  
    1414  end 
    1515 
    1616  def calling_from_template 
    17     render_template "Ring, ring: <%= render_component(:controller => 'callee', :action => 'being_called') %>" 
     17    render :inline => "Ring, ring: <%= render_component(:controller => 'callee', :action => 'being_called') %>" 
    1818  end 
    1919 
    2020  def internal_caller 
    21     render_template "Are you there? <%= render_component(:action => 'internal_callee') %>" 
     21    render :inline => "Are you there? <%= render_component(:action => 'internal_callee') %>" 
    2222  end 
    2323 
    2424  def internal_callee 
    25     render_text "Yes, ma'am" 
     25    render :text => "Yes, ma'am" 
    2626  end 
    2727 
    2828  def set_flash 
     
    3838  end 
    3939 
    4040  def calling_redirected_as_string 
    41     render_template "<%= render_component(:controller => 'callee', :action => 'redirected') %>" 
     41    render :inline => "<%= render_component(:controller => 'callee', :action => 'redirected') %>" 
    4242  end 
    4343 
    4444  def rescue_action(e) raise end 
     
    4646 
    4747class CalleeController < ActionController::Base 
    4848  def being_called 
    49     render_text "#{params[:name] || "Lady"} of the House, speaking" 
     49    render :text => "#{params[:name] || "Lady"} of the House, speaking" 
    5050  end 
    5151 
    5252  def blowing_up 
    53     render_text "It's game over, man, just game over, man!", "500 Internal Server Error" 
     53    render :text => "It's game over, man, just game over, man!", :status => 500 
    5454  end 
    5555 
    5656  def set_flash 
  • actionpack/test/controller/deprecation/deprecated_base_methods_test.rb

    old new  
    22 
    33class DeprecatedBaseMethodsTest < Test::Unit::TestCase 
    44  class Target < ActionController::Base 
    5     def deprecated_render_parameters 
    6       render "fun/games/hello_world" 
    7     end 
    85     
    96    def home_url(greeting) 
    107      "http://example.com/#{greeting}" 
     
    2522    @controller = Target.new 
    2623  end 
    2724 
    28   def test_deprecated_render_parameters 
    29     assert_deprecated("render('fun/games/hello_world')") do 
    30       get :deprecated_render_parameters 
    31     end 
    32  
    33     assert_equal "Living in a nested world", @response.body 
    34   end 
    35  
    3625  def test_log_error_silences_deprecation_warnings 
    3726    get :raises_name_error 
    3827  rescue => e 
  • actionpack/test/controller/filters_test.rb

    old new  
    234234    before_filter(AuditFilter) 
    235235 
    236236    def show 
    237       render_text "hello" 
     237      render :text => "hello" 
    238238    end 
    239239  end 
    240240 
     
    271271    before_filter :second, :only => :foo 
    272272 
    273273    def foo 
    274       render_text 'foo' 
     274      render :text => 'foo' 
    275275    end 
    276276 
    277277    def bar 
    278       render_text 'bar' 
     278      render :text => 'bar' 
    279279    end 
    280280 
    281281    protected 
  • actionpack/test/controller/cookie_test.rb

    old new  
    3333 
    3434    def delete_cookie_with_path 
    3535      cookies.delete("user_name", :path => '/beaten') 
    36       render_text "hello world" 
     36      render :text => "hello world" 
    3737    end 
    3838 
    3939    def rescue_action(e)  
  • actionpack/test/fixtures/test/_hash_greeting.erb

    old new  
  • actionpack/lib/action_controller/components.rb

    old new  
    7878        # Renders the component specified as the response for the current method 
    7979        def render_component(options) #:doc: 
    8080          component_logging(options) do 
    81             render_text(component_response(options, true).body, response.headers["Status"]) 
     81            render_for_text(component_response(options, true).body, response.headers["Status"]) 
    8282          end 
    8383        end 
    8484 
  • actionpack/lib/action_controller/benchmarking.rb

    old new  
    4343    protected 
    4444      def render_with_benchmark(options = nil, deprecated_status = nil, &block) 
    4545        unless logger 
    46           render_without_benchmark(options, deprecated_status, &block) 
     46          render_without_benchmark(options, &block) 
    4747        else 
    4848          db_runtime = ActiveRecord::Base.connection.reset_runtime if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? 
    4949 
    5050          render_output = nil 
    51           @rendering_runtime = Benchmark::measure{ render_output = render_without_benchmark(options, deprecated_status, &block) }.real 
     51          @rendering_runtime = Benchmark::measure{ render_output = render_without_benchmark(options, &block) }.real 
    5252 
    5353          if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? 
    5454            @db_rt_before_render = db_runtime 
  • actionpack/lib/action_controller/caching.rb

    old new  
    232232          if cache = controller.read_fragment(cache_path.path) 
    233233            controller.rendered_action_cache = true 
    234234            set_content_type!(controller, cache_path) 
    235             controller.send(:render_text, cache) 
     235            controller.send(:render_for_text, cache) 
    236236            false 
    237237          else 
    238238            controller.action_cache_path = cache_path 
  • actionpack/lib/action_controller/base.rb

    old new  
    1515  end 
    1616  class MissingTemplate < ActionControllerError #:nodoc: 
    1717  end 
     18  class RenderError < ActionControllerError #:nodoc: 
     19  end 
    1820  class RoutingError < ActionControllerError #:nodoc: 
    1921    attr_reader :failures 
    2022    def initialize(message, failures=[]) 
     
    609611        self.class.view_paths 
    610612      end 
    611613 
    612     protected 
    613614      # Renders the content that will be returned to the browser as the response body. 
    614615      # 
    615616      # === Rendering an action 
     
    628629      #   # but with a custom layout 
    629630      #   render :action => "long_goal", :layout => "spectacular" 
    630631      # 
    631       # _Deprecation_ _notice_: This used to have the signatures <tt>render_action("action", status = 200)</tt>, 
    632       # <tt>render_without_layout("controller/action", status = 200)</tt>, and 
    633       # <tt>render_with_layout("controller/action", status = 200, layout)</tt>. 
    634       # 
    635632      # === Rendering partials 
    636633      # 
    637634      # Partial rendering in a controller is most commonly used together with Ajax calls that only update one or a few elements on a page 
     
    698695      #   # Renders a template relative to the template root and chooses the proper file extension 
    699696      #   render :file => "some/template", :use_full_path => true 
    700697      # 
    701       # _Deprecation_ _notice_: This used to have the signature <tt>render_file(path, status = 200)</tt> 
    702       # 
    703698      # === Rendering text 
    704699      # 
    705700      # Rendering of text is usually used for tests or for rendering prepared content, such as a cache. By default, text 
     
    725720      #   # Renders "Hello from code!" 
    726721      #   render :text => proc { |response, output| output.write("Hello from code!") } 
    727722      # 
    728       # _Deprecation_ _notice_: This used to have the signature <tt>render_text("text", status = 200)</tt> 
    729       # 
    730723      # === Rendering JSON 
    731724      # 
    732725      # Rendering JSON sets the content type to text/x-json and optionally wraps the JSON in a callback. It is expected 
     
    756749      #   # Renders "hello david" 
    757750      #   render :inline => "<%= 'hello ' + name %>", :locals => { :name => "david" } 
    758751      # 
    759       # _Deprecation_ _notice_: This used to have the signature <tt>render_template(template, status = 200, type = :rhtml)</tt> 
    760       # 
    761752      # === Rendering inline JavaScriptGenerator page updates 
    762753      # 
    763754      # In addition to rendering JavaScriptGenerator page updates with Ajax in RJS templates (see ActionView::Base for details), 
     
    773764      # All renders take the :status and :location options and turn them into headers. They can even be used together: 
    774765      # 
    775766      #   render :xml => post.to_xml, :status => :created, :location => post_url(post) 
    776       def render(options = nil, deprecated_status = nil, &block) #:doc: 
     767      def render(options = nil, &block) #:doc: 
    777768        raise DoubleRenderError, "Can only render or redirect once per action" if performed? 
    778769 
    779770        if options.nil? 
    780           return render_file(default_template_name, deprecated_status, true) 
     771          return render_for_file(default_template_name, nil, true) 
    781772        else 
    782           # Backwards compatibility 
    783           unless options.is_a?(Hash) 
    784             if options == :update 
    785               options = { :update => true } 
    786             else 
    787               ActiveSupport::Deprecation.warn( 
    788                 "You called render('#{options}'), which is a deprecated API call. Instead you use " + 
    789                 "render :file => #{options}. Calling render with just a string will be removed from Rails 2.0.", 
    790                 caller 
    791               ) 
    792  
    793               return render_file(options, deprecated_status, true) 
    794             end 
     773          if options == :update 
     774            options = { :update => true } 
     775          elsif !options.is_a?(Hash) 
     776            raise RenderError, "You called render with invalid options : #{options}" 
    795777          end 
    796778        end 
    797779 
     
    804786        end 
    805787 
    806788        if text = options[:text] 
    807           render_text(text, options[:status]) 
     789          render_for_text(text, options[:status]) 
    808790 
    809791        else 
    810792          if file = options[:file] 
    811             render_file(file, options[:status], options[:use_full_path], options[:locals] || {}) 
     793            render_for_file(file, options[:status], options[:use_full_path], options[:locals] || {}) 
    812794 
    813795          elsif template = options[:template] 
    814             render_file(template, options[:status], true) 
     796            render_for_file(template, options[:status], true) 
    815797 
    816798          elsif inline = options[:inline] 
    817             render_template(inline, options[:status], options[:type], options[:locals] || {}) 
     799            add_variables_to_assigns 
     800            render_for_text(@template.render_template(options[:type] || :erb, inline, nil, options[:locals] || {}), options[:status]) 
    818801 
    819802          elsif action_name = options[:action] 
    820             ActiveSupport::Deprecation.silence do 
    821               render_action(action_name, options[:status], options[:layout]) 
    822             end 
     803            template = default_template_name(action_name.to_s) 
     804            if options[:layout] && !template_exempt_from_layout?(template) 
     805              render_with_a_layout(:file => template, :status => options[:status], :use_full_path => true, :layout => true)               
     806            else 
     807              render_with_no_layout(:file => template, :status => options[:status], :use_full_path => true) 
     808            end             
    823809 
    824810          elsif xml = options[:xml] 
    825             render_xml(xml, options[:status]) 
     811            response.content_type = Mime::XML 
     812            render_for_text(xml.respond_to?(:to_xml) ? xml.to_xml : xml, options[:status]) 
    826813 
    827814          elsif json = options[:json] 
    828             render_json(json, options[:callback], options[:status]) 
     815            json = "#{options[:callback]}(#{json})" unless options[:callback].blank? 
     816            response.content_type = Mime::JSON 
     817            render_for_text(json, options[:status]) 
    829818 
    830819          elsif partial = options[:partial] 
    831820            partial = default_template_name if partial == true 
     821            add_variables_to_assigns 
    832822            if collection = options[:collection] 
    833               render_partial_collection(partial, collection, options[:spacer_template], options[:locals], options[:status]) 
     823              render_for_text(@template.send(:render_partial_collection, partial, collection, options[:spacer_template], options[:locals]), 
     824                              options[:status]) 
    834825            else 
    835               render_partial(partial, ActionView::Base::ObjectWrapper.new(options[:object]), options[:locals], options[:status]) 
     826              render_for_text(@template.send(:render_partial, partial, ActionView::Base::ObjectWrapper.new(options[:object]), options[:locals]),  
     827                              options[:status])               
    836828            end 
    837829 
    838830          elsif options[:update] 
     
    840832            @template.send :evaluate_assigns 
    841833 
    842834            generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(@template, &block) 
    843             render_javascript(generator.to_s) 
     835            response.content_type = Mime::JS 
     836            render_for_text(generator.to_s) 
    844837 
    845838          elsif options[:nothing] 
    846839            # Safari doesn't pass the headers of the return if the response is zero length 
    847             render_text(" ", options[:status]) 
     840            render_for_text(" ", options[:status]) 
    848841 
    849842          else 
    850             render_file(default_template_name, options[:status], true) 
    851  
     843            render_for_file(default_template_name, options[:status], true) 
    852844          end 
    853845        end 
    854846      end 
     
    856848      # Renders according to the same rules as <tt>render</tt>, but returns the result in a string instead 
    857849      # of sending it as the response body to the browser. 
    858850      def render_to_string(options = nil, &block) #:doc: 
    859         ActiveSupport::Deprecation.silence { render(options, &block) } 
     851        render(options, &block) 
    860852      ensure 
    861853        erase_render_results 
    862854        forget_variables_added_to_assigns 
    863855        reset_variables_added_to_assigns 
    864856      end 
    865857 
    866       def render_action(action_name, status = nil, with_layout = true) #:nodoc: 
    867         template = default_template_name(action_name.to_s) 
    868         if with_layout && !template_exempt_from_layout?(template) 
    869           render_with_layout(:file => template, :status => status, :use_full_path => true, :layout => true) 
    870         else 
    871           render_without_layout(:file => template, :status => status, :use_full_path => true) 
    872         end 
    873       end 
    874  
    875       def render_file(template_path, status = nil, use_full_path = false, locals = {}) #:nodoc: 
    876         add_variables_to_assigns 
    877         assert_existence_of_template_file(template_path) if use_full_path 
    878         logger.info("Rendering #{template_path}" + (status ? " (#{status})" : '')) if logger 
    879         render_text(@template.render_file(template_path, use_full_path, locals), status) 
    880       end 
    881  
    882       def render_template(template, status = nil, type = :erb, local_assigns = {}) #:nodoc: 
    883         add_variables_to_assigns 
    884         render_text(@template.render_template(type, template, nil, local_assigns), status) 
    885       end 
    886  
    887       def render_text(text = nil, status = nil, append_response = false) #:nodoc: 
    888         @performed_render = true 
    889  
    890         response.headers['Status'] = interpret_status(status || DEFAULT_RENDER_STATUS_CODE) 
    891  
    892         if append_response 
    893           response.body ||= '' 
    894           response.body << text.to_s 
    895         else 
    896           response.body = text.is_a?(Proc) ? text : text.to_s 
    897         end 
    898       end 
    899  
    900       def render_javascript(javascript, status = nil, append_response = true) #:nodoc: 
    901         response.content_type = Mime::JS 
    902         render_text(javascript, status, append_response) 
    903       end 
    904  
    905       def render_xml(xml, status = nil) #:nodoc: 
    906         response.content_type = Mime::XML 
    907         render_text(xml.respond_to?(:to_xml) ? xml.to_xml : xml, status) 
    908       end 
    909  
    910       def render_json(json, callback = nil, status = nil) #:nodoc: 
    911         json = "#{callback}(#{json})" unless callback.blank? 
    912  
    913         response.content_type = Mime::JSON 
    914         render_text(json, status) 
    915       end 
    916  
    917       def render_nothing(status = nil) #:nodoc: 
    918         render_text(' ', status) 
    919       end 
    920  
    921       def render_partial(partial_path = default_template_name, object = nil, local_assigns = nil, status = nil) #:nodoc: 
    922         add_variables_to_assigns 
    923         render_text(@template.send(:render_partial, partial_path, object, local_assigns), status) 
    924       end 
    925  
    926       def render_partial_collection(partial_name, collection, partial_spacer_template = nil, local_assigns = nil, status = nil) #:nodoc: 
    927         add_variables_to_assigns 
    928         render_text(@template.send(:render_partial_collection, partial_name, collection, partial_spacer_template, local_assigns), status) 
    929       end 
    930  
    931       def render_with_layout(template_name = default_template_name, status = nil, layout = nil) #:nodoc: 
    932         render_with_a_layout(template_name, status, layout) 
    933       end 
    934  
    935       def render_without_layout(template_name = default_template_name, status = nil) #:nodoc: 
    936         render_with_no_layout(template_name, status) 
    937       end 
    938  
    939  
    940858      # Return a response that has no content (merely headers). The options 
    941859      # argument is interpreted to be a hash of header names and values. 
    942860      # This allows you to easily return a response that consists only of 
     
    10971015      end 
    10981016 
    10991017    private 
     1018 
     1019      def render_for_file(template_path, status = nil, use_full_path = false, locals = {}) #:nodoc: 
     1020        add_variables_to_assigns 
     1021        assert_existence_of_template_file(template_path) if use_full_path 
     1022        logger.info("Rendering #{template_path}" + (status ? " (#{status})" : '')) if logger 
     1023        render_for_text(@template.render_file(template_path, use_full_path, locals), status) 
     1024      end 
     1025 
     1026      def render_for_text(text = nil, status = nil, append_response = false) #:nodoc: 
     1027        @performed_render = true 
     1028 
     1029        response.headers['Status'] = interpret_status(status || DEFAULT_RENDER_STATUS_CODE) 
     1030 
     1031        if append_response 
     1032          response.body ||= '' 
     1033          response.body << text.to_s 
     1034        else 
     1035          response.body = text.is_a?(Proc) ? text : text.to_s 
     1036        end 
     1037      end 
     1038       
    11001039      def initialize_template_class(response) 
    11011040        raise "You must assign a template class through ActionController.template_class= before processing a request" unless @@template_class 
    11021041 
  • actionpack/lib/action_controller/layout.rb

    old new  
    233233    end 
    234234 
    235235    protected 
    236       def render_with_a_layout(options = nil, deprecated_status = nil, deprecated_layout = nil, &block) #:nodoc: 
     236      def render_with_a_layout(options = nil, &block) #:nodoc: 
    237237        template_with_options = options.is_a?(Hash) 
    238238 
    239         if apply_layout?(template_with_options, options) && (layout = pick_layout(template_with_options, options, deprecated_layout)) 
     239        if apply_layout?(template_with_options, options) && (layout = pick_layout(template_with_options, options)) 
    240240          assert_existence_of_template_file(layout) 
    241241 
    242242          options = options.merge :layout => false if template_with_options 
    243243          logger.info("Rendering template within #{layout}") if logger 
    244244 
    245           if template_with_options 
    246             content_for_layout = render_with_no_layout(options, &block) 
    247             deprecated_status = options[:status] || deprecated_status 
    248           else 
    249             content_for_layout = render_with_no_layout(options, deprecated_status, &block) 
    250           end 
    251  
     245          content_for_layout = render_with_no_layout(options, &block) 
    252246          erase_render_results 
    253247          add_variables_to_assigns 
    254248          @template.instance_variable_set("@content_for_layout", content_for_layout) 
    255249          response.layout = layout 
    256           render_text(@template.render_file(layout, true), deprecated_status
     250          render_for_text(@template.render_file(layout, true)
    257251        else 
    258           render_with_no_layout(options, deprecated_status, &block) 
     252          render_with_no_layout(options, &block) 
    259253        end 
    260254      end 
    261255 
     
    272266        !template_exempt_from_layout?(default_template_name(options[:action] || options[:template])) 
    273267      end 
    274268 
    275       def pick_layout(template_with_options, options, deprecated_layout) 
    276         if deprecated_layout 
    277           deprecated_layout 
    278         elsif template_with_options 
     269      def pick_layout(template_with_options, options) 
     270        if template_with_options 
    279271          case layout = options[:layout] 
    280272            when FalseClass 
    281273              nil 
  • actionpack/lib/action_controller/rescue.rb

    old new  
    125125        @template.instance_variable_set("@contents", @template.render_file(template_path_for_local_rescue(exception), false)) 
    126126 
    127127        response.content_type = Mime::HTML 
    128         render_file(rescues_path("layout"), response_code_for_rescue(exception)) 
     128        render_for_file(rescues_path("layout"), response_code_for_rescue(exception)) 
    129129      end 
    130130 
    131131    private 
  • actionpack/lib/action_view/partials.rb

    old new  
    4646  # This will render the partial "advertisement/_ad.erb" regardless of which controller this is being called from. 
    4747  module Partials 
    4848    private 
    49       # Deprecated, use render :partial 
    50       def render_partial(partial_path, local_assigns = nil, deprecated_local_assigns = nil) #:nodoc: 
     49      def render_partial(partial_path, object_assigns = nil, local_assigns = nil) #:nodoc: 
    5150        case partial_path 
    5251        when String, Symbol, NilClass 
    5352          path, partial_name = partial_pieces(partial_path) 
    54           object = extracting_object(partial_name, local_assigns, deprecated_local_assigns) 
    55           local_assigns = extract_local_assigns(local_assigns, deprecated_local_assigns) 
     53          object = extracting_object(partial_name, object_assigns) 
    5654          local_assigns = local_assigns ? local_assigns.clone : {} 
    5755          add_counter_to_local_assigns!(partial_name, local_assigns) 
    5856          add_object_to_local_assigns!(partial_name, local_assigns, object) 
     
    6866          if partial_path.any? 
    6967            path       = ActionController::RecordIdentifier.partial_path(partial_path.first) 
    7068            collection = partial_path 
    71             render_partial_collection(path, collection, nil, local_assigns.value) 
     69            render_partial_collection(path, collection, nil, object_assigns.value) 
    7270          else 
    7371            "" 
    7472          end 
    7573        else 
    7674          render_partial( 
    7775            ActionController::RecordIdentifier.partial_path(partial_path), 
    78             local_assigns, deprecated_local_assigns) 
     76            object_assigns, local_assigns) 
    7977        end 
    8078      end 
    8179 
    82       # Deprecated, use render :partial, :collection 
    8380      def render_partial_collection(partial_name, collection, partial_spacer_template = nil, local_assigns = nil) #:nodoc: 
    8481        collection_of_partials = Array.new 
    8582        counter_name = partial_counter_name(partial_name) 
     
    117114        partial_name.split('/').last.split('.').first.intern 
    118115      end 
    119116 
    120       def extracting_object(partial_name, local_assigns, deprecated_local_assigns) 
     117      def extracting_object(partial_name, object_assigns) 
    121118        variable_name = partial_variable_name(partial_name) 
    122         if local_assigns.is_a?(Hash) || local_assigns.nil? 
     119        if object_assigns.nil? 
    123120          controller.instance_variable_get("@#{variable_name}") 
    124121        else 
    125           # deprecated form where object could be passed in as second parameter 
    126           local_assigns 
     122          object_assigns 
    127123        end 
    128124      end 
    129125 
    130       def extract_local_assigns(local_assigns, deprecated_local_assigns) 
    131         local_assigns.is_a?(Hash) ? local_assigns : deprecated_local_assigns 
    132       end 
    133  
    134126      def add_counter_to_local_assigns!(partial_name, local_assigns) 
    135127        counter_name = partial_counter_name(partial_name) 
    136128        local_assigns[counter_name] = 1 unless local_assigns.has_key?(counter_name) 
  • actionpack/examples/benchmark.rb

    old new  
    77 
    88class BenchmarkController < ActionController::Base 
    99  def message 
    10     render_text "hello world" 
     10    render :text => "hello world" 
    1111  end 
    1212 
    1313  def list