class ActionDispatch::Request

def xml_http_request?

choice of JavaScript libraries and frameworks.
(case-insensitive), which may need to be manually added depending on the
Returns true if the `X-Requested-With` header contains "XMLHttpRequest"
def xml_http_request?
  /XMLHttpRequest/i.match?(get_header("HTTP_X_REQUESTED_WITH"))
end