0

I have a controller that looks like this:

class DataController < ApplicationController::Base
  def index
    @data = Data.all
    render json: @data, each_seralizer: DataSerializer
  end
end

And I'm using ActiveModel::Serializer to serialize the data. The problem is that when I navigate to the url in my browser, it responds by sending a file data.json instead of just rendering the json. If I do render body: DataSerializer.new(@some_record).to_json it renders the json in the browser as expected.

What am I missing?

Thank's in advance.

EDIT: I realized this only happens for me in IE, not in Chrome for example. So perhaps a browser setting?

Majoren
  • 983
  • 5
  • 16
  • 36
  • 3
    IE is just *#€ stupid. Some versions don't recognize the `application/json` mimetype and instead of rendering it as text/plain as a sensible browser does when it encounters a unknown mime IE promts the user to download the file. See http://stackoverflow.com/questions/13943439/json-response-download-in-ie710 – max Mar 10 '16 at 12:43
  • I see, well thank you for the explanation about the mime type. – Majoren Mar 10 '16 at 13:33

0 Answers0