I have a rails application in which most of the actions respond to json.
Is there any "switch" I can turn off to prevent all the controllers from responding to json despite the
I have a proposal, though a bit hacky I'm afraid :)
class < ApplicationController before_filter :disable_json def disable_json if request.format =~ /json/ //do something you like, redirect_to or reply with message end end
The before_filter will be fired before any specific controller's method.
The json header is usually "application/json"
request, you can read more here: http://guides.rubyonrails.org/action_controller_overview.html#the-request-object