Ruby on rails 重写Rails中的MIME类型
我想将Rails中的JSON MIME类型(“application/JSON”)重写为(“text/x-JSON”)。我试图在MIME_types.rb中再次注册MIME类型,但没有成功。有什么建议吗 谢谢。试试:Ruby on rails 重写Rails中的MIME类型,ruby-on-rails,ruby,json,mime,mime-types,Ruby On Rails,Ruby,Json,Mime,Mime Types,我想将Rails中的JSON MIME类型(“application/JSON”)重写为(“text/x-JSON”)。我试图在MIME_types.rb中再次注册MIME类型,但没有成功。有什么建议吗 谢谢。试试: render :json => var_containing_my_json, :content_type => 'text/x-json' 这应该有效(在初始值设定项、插件或类似的地方): Mime.send(:remove_const, :JSON) Mime::
render :json => var_containing_my_json, :content_type => 'text/x-json'
这应该有效(在初始值设定项、插件或类似的地方):
Mime.send(:remove_const, :JSON)
Mime::Type.register "text/x-json", :json