我想在Rails中覆盖JSON MIME类型(“application / json”)(“text / x-json”)。我试图在mime_types.rb中再次注册MIME类型,但这不起作用。有什么建议吗?
感谢。
答案 0 :(得分:11)
这应该有效(在初始化器,插件或类似的地方):
Mime.send(:remove_const, :JSON)
Mime::Type.register "text/x-json", :json
答案 1 :(得分:3)
尝试:
render :json => var_containing_my_json, :content_type => 'text/x-json'