Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将 Rails 中的 JSON MIME 类型(“application/json”)覆盖为(“text/x-json”)。我尝试在 mime_types.rb 中再次注册 MIME 类型,但没有成功。有什么建议么?
谢谢。
这应该可以工作(在初始化程序、插件或类似的地方):
Mime.send(:remove_const, :JSON) Mime::Type.register "text/x-json", :json
尝试:
render :json => var_containing_my_json, :content_type => 'text/x-json'