JP Richardson
JP Richardson

Reputation: 39395

Overriding a MIME type in Rails

I want to override the JSON MIME type ("application/json") in Rails to ("text/x-json"). I tried to register the MIME type again in mime_types.rb but that didn't work. Any suggestions?

Thanks.

Upvotes: 4

Views: 5965

Answers (2)

Ben Scofield
Ben Scofield

Reputation: 6418

This should work (in an initializer, plugin, or some similar place):

Mime.send(:remove_const, :JSON)
Mime::Type.register "text/x-json", :json

Upvotes: 11

Mike Tunnicliffe
Mike Tunnicliffe

Reputation: 10772

Try:

render :json => var_containing_my_json, :content_type => 'text/x-json'

Upvotes: 3

Related Questions