module ActionDispatch::Http::URL

def url

req.url # => "http://example.com"
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com'

Returns the complete URL used for this request.
def url
  protocol + host_with_port + fullpath
end