Forum: Ruby on Rails Which request-method returns the whole REQUEST_URI?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fc582698581884352e745d1d4c64699d?d=identicon&s=25 Joshua Muheim (josh)
on 2007-04-03 18:01
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. :-)

Josh
This topic is locked and can not be replied to.