How to globally PREVENT json rendering in rails? -
i have rails application in of actions respond json.
is there "switch" can turn off prevent controllers responding json despite respond_to
method call, or still have disable manually in every action (which seems odd).
i have proposal, though bit hacky i'm afraid :)
class < applicationcontroller before_filter :disable_json def disable_json if request.format =~ /json/ //do like, redirect_to or reply message end end
the before_filter fired before specific controller's method.
the json header "application/json"
for request
, can read more here: http://guides.rubyonrails.org/action_controller_overview.html#the-request-object
Comments
Post a Comment