Thanks for the replies. Got that working.

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Pat Allan
Sent: Tuesday, January 27, 2009 1:28 PM
To: [email protected]
Subject: [ts] Re: on form with multiple search buttons that access different
indexes and models


You need to have both buttons having the same name, but different  
values (and for buttons, values are the text). So, maybe something like:

<%= submit_tag "Search Customers", :name => "mode" %>
<%= submit_tag "Search Groceries", :name => "mode" %>


And then in the controller:

def search
   klass = case params[:mode]
   when "Search Customers"
     Customer
   when "Search Groceries"
     Grocery
   end

   @results = klass.search params[:query],
     :page => params[:page],
     :per_page => SEARCH_PAGE_NO
   }

   # ...
end

Hopefully this helps.

Cheers

-- 
Pat

On 22/01/2009, at 11:19 PM, tyliong wrote:

>
> Hi,
>
> i want to have one form that has multiple search buttons. Something
> like what google has (search and I'm feeling lucky). In this case I
> want to have one search button to search the model groceries and the
> other search button to search customers.
>
> my search view is currently this:
>
>                                       <% form_tag '/search', :method =>
"get" do %>
>                                       <%= text_field_tag("query",
params['query'], :size => 30 )   %>
>                                       <%= submit_tag  "Search" %>
>                                       <% end%>
> my groceries controller is this:
>
>                       def search
>                       @grocery = Grocery.search params[:query], {:page =>
params
> [:page], :per_page => SEARCH_PAGE_NO}
>                       end
> >




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to