Which request-method returns the whole REQUEST_URI?


#1

Hi all

I need to display the whole address that’s in the address bar of the
browser in a view.

http://localhost:3000/my_controller/my_action

I tried with request.request_uri, but sadly this only gives me the path
after the domain and port:

/my_controller/my_action

I saw that request.env_table[‘REQUEST_URI’] gives me the wanted result,
but it seems that this is not available in testing environment.

So i hacked this dirty little helper:

def whole_url
protocol + host_with_port + request_uri
end

But I guess it’s not very error proven, because what happens when the
default port is used and I only need

http://www.mysite.xxx/my_controller/my_action

but whole_url gives me

http://www.mysite.xxx:80/my_controller/my_action

? So I guess there’s for sure a better way to solve my problem… Any
hints? Thanks. :slight_smile:

Josh