Chad Johnson
Chad Johnson

Reputation: 21895

Possible to retrieve actual raw URL for Rails request?

I want to retrieve the actual, encoded URL value for a page I visit in my Rails application.

So, if I visit http://domain.com/dir/test%2Bpath, I should get the value "http://domain.com/dir/test%2Bpath" and NOT "http://domain.com/dir/test+path".

Is there ANY way to do this? I've inspected the Request object, Googled...nothing.

Upvotes: 0

Views: 556

Answers (2)

Michael Slade
Michael Slade

Reputation: 13877

In my system I can use request.url and request.path:

(rdb:1) request.url
"http://localhost:3000/test2/path/a%2Bb"
(rdb:1) request.path
"/test2/path/a%2Bb"

This should work in the controller or the view.

Upvotes: 1

naren
naren

Reputation: 937

You can use ruby helper method

URI.unescape('http://domain.com/dir/test%2Bpath')

Upvotes: 0

Related Questions