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

Changeset 8862

Show
Ignore:
Timestamp:
02/12/08 22:42:36 (5 months ago)
Author:
nzkoz
Message:

Make sure render :update support the options hash. Closes #11088 [ernesto.jimenez]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/base.rb

    r8805 r8862  
    835835      # 
    836836      #   render :xml => post.to_xml, :status => :created, :location => post_url(post) 
    837       def render(options = nil, &block) #:doc: 
     837      def render(options = nil, extra_options = {}, &block) #:doc: 
    838838        raise DoubleRenderError, "Can only render or redirect once per action" if performed? 
    839839 
    840840        if options.nil? 
    841841          return render_for_file(default_template_name, nil, true) 
     842        elsif !extra_options.is_a?(Hash) 
     843          raise RenderError, "You called render with invalid options : #{options}, #{extra_options}" 
    842844        else 
    843845          if options == :update 
    844             options = { :update => true } 
     846            options = extra_options.merge({ :update => true }) 
    845847          elsif !options.is_a?(Hash) 
    846848            raise RenderError, "You called render with invalid options : #{options}" 
     
    911913            generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(@template, &block) 
    912914            response.content_type = Mime::JS 
    913             render_for_text(generator.to_s
     915            render_for_text(generator.to_s, options[:status]
    914916 
    915917          elsif options[:nothing] 
  • trunk/actionpack/lib/action_controller/benchmarking.rb

    r8355 r8862  
    4242 
    4343    protected 
    44       def render_with_benchmark(options = nil, deprecated_status = nil, &block) 
     44      def render_with_benchmark(options = nil, extra_options = {}, &block) 
    4545        unless logger 
    46           render_without_benchmark(options, &block) 
     46          render_without_benchmark(options, extra_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, &block) }.real 
     51          @rendering_runtime = Benchmark::measure{ render_output = render_without_benchmark(options, extra_options, &block) }.real 
    5252 
    5353          if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? 
  • trunk/actionpack/lib/action_controller/layout.rb

    r8683 r8862  
    244244 
    245245    protected 
    246       def render_with_a_layout(options = nil, &block) #:nodoc: 
     246      def render_with_a_layout(options = nil, extra_options = {}, &block) #:nodoc: 
    247247        template_with_options = options.is_a?(Hash) 
    248248         
     
    253253          logger.info("Rendering template within #{layout}") if logger 
    254254 
    255           content_for_layout = render_with_no_layout(options, &block) 
     255          content_for_layout = render_with_no_layout(options, extra_options, &block) 
    256256          erase_render_results 
    257257          add_variables_to_assigns 
     
    261261          render_for_text(@template.render_file(layout, true), status) 
    262262        else 
    263           render_with_no_layout(options, &block) 
     263          render_with_no_layout(options, extra_options, &block) 
    264264        end 
    265265      end 
  • trunk/actionpack/test/controller/render_test.rb

    r8805 r8862  
    6060  def render_custom_code 
    6161    render :text => "hello world", :status => 404 
     62  end 
     63 
     64  def render_custom_code_rjs 
     65    render :update, :status => 404 do |page| 
     66      page.replace :foo, :partial => 'partial' 
     67    end 
    6268  end 
    6369 
     
    289295  end 
    290296 
     297  def test_render_custom_code_rjs 
     298    get :render_custom_code_rjs 
     299    assert_response 404 
     300    assert_equal %(Element.replace("foo", "partial html");), @response.body 
     301  end 
     302 
    291303  def test_render_text_with_nil 
    292304    get :render_text_with_nil