Changeset 8862
- Timestamp:
- 02/12/08 22:42:36 (9 months ago)
- Files:
-
- trunk/actionpack/lib/action_controller/base.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_controller/benchmarking.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/layout.rb (modified) (3 diffs)
- trunk/actionpack/test/controller/render_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/base.rb
r8805 r8862 835 835 # 836 836 # 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: 838 838 raise DoubleRenderError, "Can only render or redirect once per action" if performed? 839 839 840 840 if options.nil? 841 841 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}" 842 844 else 843 845 if options == :update 844 options = { :update => true }846 options = extra_options.merge({ :update => true }) 845 847 elsif !options.is_a?(Hash) 846 848 raise RenderError, "You called render with invalid options : #{options}" … … 911 913 generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(@template, &block) 912 914 response.content_type = Mime::JS 913 render_for_text(generator.to_s )915 render_for_text(generator.to_s, options[:status]) 914 916 915 917 elsif options[:nothing] trunk/actionpack/lib/action_controller/benchmarking.rb
r8355 r8862 42 42 43 43 protected 44 def render_with_benchmark(options = nil, deprecated_status = nil, &block)44 def render_with_benchmark(options = nil, extra_options = {}, &block) 45 45 unless logger 46 render_without_benchmark(options, &block)46 render_without_benchmark(options, extra_options, &block) 47 47 else 48 48 db_runtime = ActiveRecord::Base.connection.reset_runtime if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? 49 49 50 50 render_output = nil 51 @rendering_runtime = Benchmark::measure{ render_output = render_without_benchmark(options, &block) }.real51 @rendering_runtime = Benchmark::measure{ render_output = render_without_benchmark(options, extra_options, &block) }.real 52 52 53 53 if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? trunk/actionpack/lib/action_controller/layout.rb
r8683 r8862 244 244 245 245 protected 246 def render_with_a_layout(options = nil, &block) #:nodoc:246 def render_with_a_layout(options = nil, extra_options = {}, &block) #:nodoc: 247 247 template_with_options = options.is_a?(Hash) 248 248 … … 253 253 logger.info("Rendering template within #{layout}") if logger 254 254 255 content_for_layout = render_with_no_layout(options, &block)255 content_for_layout = render_with_no_layout(options, extra_options, &block) 256 256 erase_render_results 257 257 add_variables_to_assigns … … 261 261 render_for_text(@template.render_file(layout, true), status) 262 262 else 263 render_with_no_layout(options, &block)263 render_with_no_layout(options, extra_options, &block) 264 264 end 265 265 end trunk/actionpack/test/controller/render_test.rb
r8805 r8862 60 60 def render_custom_code 61 61 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 62 68 end 63 69 … … 289 295 end 290 296 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 291 303 def test_render_text_with_nil 292 304 get :render_text_with_nil