# Which request-method returns the whole REQUEST\_URI?

**URL:** <https://www.ruby-forum.com/t/which-request-method-returns-the-whole-request-uri/90998>\
**Category:** Rails\
**Created:** [April 3, 2007, 6:01pm UTC](https://www.ruby-forum.com/t/which-request-method-returns-the-whole-request-uri/90998 "2007-04-03T18:01:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 3, 2007, 6:01pm UTC](https://www.ruby-forum.com/t/which-request-method-returns-the-whole-request-uri/90998/1 "2007-04-03T18:01:54Z")

</div>

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](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](http://www.mysite.xxx/my_controller/my_action)

but whole\_url gives me

[http://www.mysite.xxx:80/my\_controller/my\_action](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. 🙂

Josh
