Changeset 6572
- Timestamp:
- 04/24/07 17:52:03 (1 year ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/base.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/render_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r6547 r6572 1 1 *SVN* 2 3 * Added :location option to render so that the common pattern of rendering a response after creating a new resource is now a 1-liner [DHH] 4 5 render :xml => post.to_xml, :status => :created, :location => post_url(post) 2 6 3 7 * Ensure that render_text only adds string content to the body of the response [DHH] trunk/actionpack/lib/action_controller/base.rb
r6560 r6572 744 744 # end 745 745 # 746 # === Rendering nothing 747 # 748 # Rendering nothing is often convenient in combination with Ajax calls that perform their effect client-side or 749 # when you just want to communicate a status code. Due to a bug in Safari, nothing actually means a single space. 750 # 751 # # Renders an empty response with status code 200 752 # render :nothing => true 753 # 754 # # Renders an empty response with status code 401 (access denied) 755 # render :nothing => true, :status => 401 746 # === Rendering with status and location headers 747 # 748 # All renders take the :status and :location options and turn them into headers. They can even be used together: 749 # 750 # render :xml => post.to_xml, :status => :created, :location => post_url(post) 756 751 def render(options = nil, deprecated_status = nil, &block) #:doc: 757 752 raise DoubleRenderError, "Can only render or redirect once per action" if performed? … … 778 773 if content_type = options[:content_type] 779 774 response.content_type = content_type.to_s 775 end 776 777 if location = options[:location] 778 response.headers["Location"] = location 780 779 end 781 780 trunk/actionpack/test/controller/render_test.rb
r6517 r6572 72 72 def heading 73 73 head :ok 74 end 75 76 def location 77 render :xml => "<hello/>", :location => "http://example.com", :status => 201 74 78 end 75 79 … … 369 373 end 370 374 375 def test_rendering_with_location_should_set_header 376 get :location 377 assert_equal "http://example.com", @response.headers["Location"] 378 end 379 380 371 381 protected 372 382 def assert_deprecated_render(&block)