# URL parameters

**URL:** <https://www.ruby-forum.com/t/url-parameters/138860>\
**Category:** Rails\
**Created:** [May 28, 2008, 1:28pm UTC](https://www.ruby-forum.com/t/url-parameters/138860 "2008-05-28T13:28:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shawn\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/977dab/32.png) [@Shawn\_B](https://www.ruby-forum.com/u/Shawn_B)\
**Post date:** [May 28, 2008, 1:28pm UTC](https://www.ruby-forum.com/t/url-parameters/138860/1 "2008-05-28T13:28:22Z")

</div>

Can someone help me please. I have a form on one page that is  
functioning as a search form. After I get the results on the next page  
I would like to be also able to read the search options selected which  
are in the URL of the results page. What is need for me to be able to  
do some conditional statements against them.

---

<div class="post-metadata">

**Author:** ![Shawn\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/977dab/32.png) [@Shawn\_B](https://www.ruby-forum.com/u/Shawn_B)\
**Post date:** [May 28, 2008, 1:31pm UTC](https://www.ruby-forum.com/t/url-parameters/138860/2 "2008-05-28T13:31:22Z")

</div>

try \<%= params[:id] %\>

---

<div class="post-metadata">

**Author:** ![Shawn\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/977dab/32.png) [@Shawn\_B](https://www.ruby-forum.com/u/Shawn_B)\
**Post date:** [May 28, 2008, 1:53pm UTC](https://www.ruby-forum.com/t/url-parameters/138860/3 "2008-05-28T13:53:38Z")

</div>

what Ajit wanted to show is that all the parameters in the url are  
available in the params hash

for an url like that

> [http://localhost:3000/companies?test=test&province=&building\_systems=1&wood\_based\_panels=1](http://localhost:3000/companies?test=test&province=&building_systems=1&wood_based_panels=1)

you should have  
params[:test] containing “test”  
params[:province] is empty  
params[:building\_system] containing “1” (as a string!)  
and so on

you van use that in your controller code like

if params[:building\_system] == “1” then  
… do something …  
end

or in your erb code like Ajit showed.

---

<div class="post-metadata">

**Author:** ![Shawn\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/977dab/32.png) [@Shawn\_B](https://www.ruby-forum.com/u/Shawn_B)\
**Post date:** [May 28, 2008, 1:45pm UTC](https://www.ruby-forum.com/t/url-parameters/138860/4 "2008-05-28T13:45:06Z")

</div>

dosen’t seem to work. this is the URL with the Paramaters that I am  
wanting to grab  
[http://localhost:3000/companies?test=test&province=&building\_systems=1&wood\_based\_panels=1](http://localhost:3000/companies?test=test&province=&building_systems=1&wood_based_panels=1)
