You can set the type inside the action with
request.format = :json
I tested it using
class ExampleController < ApplicationController def always_accept_json request.format = :json respond_to do |format| format.json { raise "HEY" } format.html end end end
What can you do in any ActionController, i.e. if you want at the top level that the entire request appears in your application as content_type application/json , just make it a filter on application_controller.rb that sets request.format
source share