Substituindo um tipo MIME em Rails
-
01-07-2019 - |
Pergunta
Eu quero substituir o tipo JSON MIME ( "application / json") no Rails para ( "text / x-json"). Tentei registrar o tipo de MIME novamente em mime_types.rb mas isso não funcionou. Alguma sugestão?
Graças.
Solução
Isso deve funcionar (em um inicializador, plugin, ou algum lugar similar):
Mime.send(:remove_const, :JSON)
Mime::Type.register "text/x-json", :json
Outras dicas
Tente:
render :json => var_containing_my_json, :content_type => 'text/x-json'
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow