class ActionDispatch::Request

def local?

True if the request came from localhost, 127.0.0.1, or ::1.
def local?
  LOCALHOST.match?(remote_addr) && LOCALHOST.match?(remote_ip)
end