link_to query mysql for list

J

Jerry Jones

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. =)
 
K

Keynan Pratt

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]]
 
R

Rick DeNatale

<%= 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' %>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,260
Messages
2,571,308
Members
47,964
Latest member
ConnieBold

Latest Threads

Top