# Noob question on passing parameters in the url

**URL:** <https://www.ruby-forum.com/t/noob-question-on-passing-parameters-in-the-url/188346>\
**Category:** Rails\
**Created:** [May 10, 2010, 4:14pm UTC](https://www.ruby-forum.com/t/noob-question-on-passing-parameters-in-the-url/188346 "2010-05-10T16:14:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lille](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@Lille](https://www.ruby-forum.com/u/Lille)\
**Post date:** [May 10, 2010, 4:14pm UTC](https://www.ruby-forum.com/t/noob-question-on-passing-parameters-in-the-url/188346/1 "2010-05-10T16:14:30Z")

</div>

Hi,

What are the requirements for passing parameters in the url across any  
controller/action combinations?

[from controller A…] redirect\_to  
controller\_b\_action1\_url(:desired\_param=\>‘desired value’)

[now from B#1…] redirect\_to  
controller\_b\_action2\_url(:desired\_param=\>params[:desired\_param])

[from B#2…] redirect\_to  
controller\_a\_action2\_url(:desired\_param=\>params[:desired\_param])

[now from A#2…] redirect\_to  
controller\_a\_action3\_url(:desired\_param=\>params[:desired\_param])

Do my routes need to have only certain request actions associated,  
e.g., post or put, for this to work? My attempts so far have seemed to  
require the use of hidden fields in views to ‘save’ my desired  
parameters for use between calls – I don’t like this approach.

Thanks for any comment,

Lille

---

<div class="post-metadata">

**Author:** ![Lille](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@Lille](https://www.ruby-forum.com/u/Lille)\
**Post date:** [May 10, 2010, 6:40pm UTC](https://www.ruby-forum.com/t/noob-question-on-passing-parameters-in-the-url/188346/2 "2010-05-10T18:40:50Z")

</div>

Lille wrote:

> Hi,
> 
> What are the requirements for passing parameters in the url across any  
> controller/action combinations?
> 
> [from controller A…] redirect\_to  
> controller\_b\_action1\_url(:desired\_param=\>‘desired value’)
> 
> [now from B#1…] redirect\_to  
> controller\_b\_action2\_url(:desired\_param=\>params[:desired\_param])
> 
> [from B#2…] redirect\_to  
> controller\_a\_action2\_url(:desired\_param=\>params[:desired\_param])
> 
> [now from A#2…] redirect\_to  
> controller\_a\_action3\_url(:desired\_param=\>params[:desired\_param])
> 
> Do my routes need to have only certain request actions associated,  
> e.g., post or put, for this to work?

I believe extra URL parameters (that is, not specified in routes, but  
put in the query string) only work on GET.

> My attempts so far have seemed to  
> require the use of hidden fields in views to ‘save’ my desired  
> parameters for use between calls – I don’t like this approach.

Have you considered session variables?

> Thanks for any comment,
> 
> Lille

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Lille](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@Lille](https://www.ruby-forum.com/u/Lille)\
**Post date:** [May 10, 2010, 7:07pm UTC](https://www.ruby-forum.com/t/noob-question-on-passing-parameters-in-the-url/188346/3 "2010-05-10T19:07:15Z")

</div>

Marnen,

Thanks, I will experiment with GET and extra URL parameters. My work  
thus far suggests, however, this will be a difficult requirement if my  
goal is to pass extra URL parameters across any controller/action  
combination.

Yes, session variables seem a natural here, but I like the idea of my  
users seeing the persistence of certain identifiers. I send my users  
through a bunch of ‘test pages’ during which they might like to be  
reassured that the tests are being applied to the entity of interest  
to them, e.g., params[:id=\>‘1-my\_entity\_of\_interest’].

Thanks,

Lille
