Reputation: 21895
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
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
Reputation: 937
You can use ruby helper method
URI.unescape('http://domain.com/dir/test%2Bpath')
Upvotes: 0