# How do I pass a variable to a query in a url (noob question)

**URL:** <https://www.ruby-forum.com/t/how-do-i-pass-a-variable-to-a-query-in-a-url-noob-question/107257>\
**Category:** Rails\
**Created:** [June 19, 2007, 6:30pm UTC](https://www.ruby-forum.com/t/how-do-i-pass-a-variable-to-a-query-in-a-url-noob-question/107257 "2007-06-19T18:30:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lyntaff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/87869e/32.png) [@lyntaff](https://www.ruby-forum.com/u/lyntaff)\
**Post date:** [June 19, 2007, 6:30pm UTC](https://www.ruby-forum.com/t/how-do-i-pass-a-variable-to-a-query-in-a-url-noob-question/107257/1 "2007-06-19T18:30:14Z")

</div>

I am a noobie to rails and have just started building my own rails  
project. I successfully built a simple crud admin and added all the  
records into a mysql database ready to build a public product  
catalouge.

I have displayed a browse section of the application with a links of  
categories from the database and want have a page which displays a  
list of products from the appropriate category is selected.

Can someone point me in the right direction? Your help will be much  
appreciated.

LYN

---

<div class="post-metadata">

**Author:** ![lyntaff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/87869e/32.png) [@lyntaff](https://www.ruby-forum.com/u/lyntaff)\
**Post date:** [June 20, 2007, 4:42pm UTC](https://www.ruby-forum.com/t/how-do-i-pass-a-variable-to-a-query-in-a-url-noob-question/107257/2 "2007-06-20T16:42:53Z")

</div>

link\_to ‘Some Category’, :controller =\> ‘categories’, :action =\>  
‘show’, :id =\> category

There are several ways to do links now adays, especially with the  
introduction of RESTful routing… you should have a look at routing  
and buy the latest Agile Development with Rails book.
