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.
这应该工作(在初始化程序,插件或一些类似的地方):
Mime.send(:remove_const, :JSON)
Mime::Type.register "text/x-json", :json
尝试:
render :json => var_containing_my_json, :content_type => 'text/x-json'
链接地址: http://www.djcxy.com/p/1218.html
上一篇: REST API错误返回最佳做法
下一篇: 在Rails中覆盖MIME类型