module ActionDispatch::Http::URL

def url

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

end
include ActionDispatch::Http::URL
class Request < Rack::Request

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