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?
  @env['HTTP_X_REQUESTED_WITH'] =~ /XMLHttpRequest/i
end