You can do the following to disable Rails' automatic handling of the .ext
format:
constraints format: false do
resources :apples
# ...
end
Then, and this is a bit gross but I don't see a better way to do this at the moment, you can do the following to update ActionController on what format to serve:
class ApplicationController < ActionController::Base
before_filter :set_format_from_query_string
private
def set_format_from_query_string
request.format = params.fetch(:_format, 'json')
end
end
This will allow your respond_to
block to toggle based on the _format
query string parameter and uses json
as the default format.