# Link\_to query mysql for list

**URL:** <https://www.ruby-forum.com/t/link-to-query-mysql-for-list/105948>\
**Category:** Ruby\
**Created:** [June 4, 2007, 10:02pm UTC](https://www.ruby-forum.com/t/link-to-query-mysql-for-list/105948 "2007-06-04T22:02:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerryjj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9d8465/32.png) [@jerryjj](https://www.ruby-forum.com/u/jerryjj)\
**Post date:** [June 4, 2007, 10:02pm UTC](https://www.ruby-forum.com/t/link-to-query-mysql-for-list/105948/1 "2007-06-04T22:02:32Z")

</div>

I have a web app that I want to make a link. I have a link\_to that  
will show the entire list of an inventory table, but I want another  
link that will select only items of a certain name.  
Here is my show all link  
\<%= link\_to ‘View Jewelry’, {:controller =\> “inventory\_item”, :action  
=\> “list”} %\>

I am unable to find a reference/example to show me how to do this. I  
am new, please be gentle with me. =)

---

<div class="post-metadata">

**Author:** ![jerryjj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9d8465/32.png) [@jerryjj](https://www.ruby-forum.com/u/jerryjj)\
**Post date:** [June 4, 2007, 10:42pm UTC](https://www.ruby-forum.com/t/link-to-query-mysql-for-list/105948/2 "2007-06-04T22:42:13Z")

</div>

use the rails forum for ror questions  
\<%= link\_to ‘View Jewelry’, {:controller =\> “inventory\_item”, :action =\>  
“list”} %\>

becomes

\<%= link\_to ‘View Jewelry’, {:controller =\> “inventory\_item”, :action =\>  
“list”, :name = ‘some\_name’} %\>

and in the controller you need to say if there is a name provided find  
:all, :conditions =\> [‘name = ?’, params[:name]]

---

<div class="post-metadata">

**Author:** ![jerryjj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9d8465/32.png) [@jerryjj](https://www.ruby-forum.com/u/jerryjj)\
**Post date:** [June 4, 2007, 11:28pm UTC](https://www.ruby-forum.com/t/link-to-query-mysql-for-list/105948/3 "2007-06-04T23:28:44Z")

</div>

On 6/4/07, Keynan P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \<%= link\_to ‘View Jewelry’, {:controller =\> “inventory\_item”, :action =\>  
> “list”, :name = ‘some\_name’} %\>

actually

\<%= link\_to ‘View Jewelry’, {:controller =\> “inventory\_item”, :action  
=\> “list”, :name =\> ‘some\_name’} %\>

and you can drop those brackets so:

## \<%= link\_to ‘View Jewelry’, :controller =\> “inventory\_item”, :action =\> “list”, :name =\> ‘some\_name’ %\>

Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)
