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

Ticket #10388 (closed defect: fixed)

Opened 10 months ago

Last modified 10 months ago

[PATCH] preserving custom content_type for render :xml and :json

Reported by: jmettraux Assigned to: core
Priority: normal Milestone: 2.x
Component: ActionPack Version: edge
Severity: normal Keywords: render xml atom content_type JSON
Cc:

Description

The current (Edge and 2.0.0 RC 2) Rails will override custom content types for XML, JSON (and JS).

I'm using Rails to generate Atom[Pub] documents where content-type might be something like "application/atomsvc+xml" instead of the MIME::XML standard of "application/xml".

render(

:xml => generate_atompub_service_document, :content_type => "application/atomsvc+xml")

The path attached here ensures that ActionController::Base respects custom content_type for XML and JSON (not 100% about this last one).

It features a new test method and adds an assertion to a render_xml test to make sure that by default, the content-type is still "application/xml".

This patch might be useful for people working with the Atom[Pub].

Attachments

preserve_custom_content-type.diff (1.9 kB) - added by jmettraux on 12/06/07 02:04:42.
preserve_custom_content-type.with_json_test.diff (4.3 kB) - added by chuyeow on 12/06/07 02:24:35.
Added JSON test

Change History

12/06/07 02:04:42 changed by jmettraux

  • attachment preserve_custom_content-type.diff added.

12/06/07 02:06:39 changed by jmettraux

  • keywords set to render xml atom content_type.

12/06/07 02:22:33 changed by jmettraux

  • milestone deleted.

12/06/07 02:24:35 changed by chuyeow

  • attachment preserve_custom_content-type.with_json_test.diff added.

Added JSON test

12/06/07 02:26:31 changed by chuyeow

  • keywords changed from render xml atom content_type to render xml atom content_type JSON.
  • milestone set to 2.x.

+1. Looks good.

Added a test for the JSON case.

Also removed the "do_with"s in the other test names which really don't add any descriptive value.

12/09/07 22:11:40 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [8342]) render :xml and :json preserve custom content types. Closes #10388.