# Reconstructing url with complex params

**URL:** <https://www.ruby-forum.com/t/reconstructing-url-with-complex-params/132498>\
**Category:** Rails\
**Created:** [March 20, 2008, 7:27pm UTC](https://www.ruby-forum.com/t/reconstructing-url-with-complex-params/132498 "2008-03-20T19:27:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e47774/32.png) [@vikram](https://www.ruby-forum.com/u/vikram)\
**Post date:** [March 20, 2008, 7:27pm UTC](https://www.ruby-forum.com/t/reconstructing-url-with-complex-params/132498/1 "2008-03-20T19:27:02Z")

</div>

Hi,  
From my rails app, i need a way to reconstruct the current request  
url inside rhtml so that i can redirect to load the complete page in  
some other canvas. For that, i need all query string parameters. I  
managed to construct the whole URL, but for cases where i have complex  
params like abc[x]=Hello, abc[y]=world, i could only get to the extent  
where i fetch them using reqest.query\_parameters as a hash. But, how  
do i reconstruct them into the URL? I may have to construct something  
like abc%5Bx%5D%3DHello%26abc%5By%5D%3Dworld (encoded).  
Or, is there a cleaner way of getting a lossless complete url of the  
current page with all the params?

-Vikram

---

<div class="post-metadata">

**Author:** ![vikram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e47774/32.png) [@vikram](https://www.ruby-forum.com/u/vikram)\
**Post date:** [March 20, 2008, 7:55pm UTC](https://www.ruby-forum.com/t/reconstructing-url-with-complex-params/132498/2 "2008-03-20T19:55:23Z")

</div>

“Vikram” writes:

> Hi,  
> From my rails app, i need a way to reconstruct the current  
> request  
> url inside rhtml so that i can redirect to load the complete  
> page in  
> some other canvas. For that, i need all query string  
> parameters. I  
> managed to construct the whole URL, but for cases where i have  
> complex  
> params like abc[x]=Hello, abc[y]=world, i could only get to the  
> extent  
> where i fetch them using reqest.query\_parameters as a hash.  
> But, how  
> do i reconstruct them into the URL? I may have to construct  
> something  
> like abc%5Bx%5D%3DHello%26abc%5By%5D%3Dworld (encoded).  
> Or, is there a cleaner way of getting a lossless complete url  
> of the  
> current page with all the params?

I recommend using the url\_for(:overwrite\_params =\> {}) construct  
as it allows you to overwrite controller, action as well as  
parameters while retaining most of the original request url.

– Long  
[http://FATdrive.tv/wall/trakb/10-Long](http://FATdrive.tv/wall/trakb/10-Long)  
[http://FATdrive.tv/](http://FATdrive.tv/) - store, play, share

---

<div class="post-metadata">

**Author:** ![vikram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e47774/32.png) [@vikram](https://www.ruby-forum.com/u/vikram)\
**Post date:** [March 20, 2008, 7:30pm UTC](https://www.ruby-forum.com/t/reconstructing-url-with-complex-params/132498/3 "2008-03-20T19:30:01Z")

</div>

> From my rails app, i need a way to reconstruct the current request  
> url inside rhtml so that i can redirect to load the complete page in  
> some other canvas. For that, i need all query string parameters. I  
> managed to construct the whole URL, but for cases where i have complex  
> params like abc[x]=Hello, abc[y]=world, i could only get to the extent  
> where i fetch them using reqest.query\_parameters as a hash. But, how  
> do i reconstruct them into the URL? I may have to construct something  
> like abc%5Bx%5D%3DHello%26abc%5By%5D%3Dworld (encoded).  
> Or, is there a cleaner way of getting a lossless complete url of the  
> current page with all the params?

Would this work?

url\_for(params)

?
