Forum: Ruby on Rails Search Form

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Armitage (Guest)
on 2007-06-22 16:48
(Received via mailing list)
Hi All
this is driving me batty.
I am trying to do a search, the form I have created has radio buttons
and a text field

<p>Staff Number<%= radio_button_tag(:search,:staff,0) %>
NI Number<%= radio_button_tag(:search, :staff, 1) %>
File Number<%= radio_button_tag(:search, :staff, 2) %>
name<%= radio_button_tag(:search, :staff, 3) %></p>
<p><%= text_field(:search_text, "", "size"=>10)%></p>

The controller should then check which button is checked and search as
appropriate, there is placeholder text for this as the moment as no
matter which button I check, I always get the same output!
def staff_search
    @search_text = params[:search]
    @word = params[:search_text]
     if @search_text = "staff0"
       @word = 1
       if @search_text = "staff1"
         @word = 2
         if @search_text = "staff2"
            @word = 3
            else @word = 2
This topic is locked and can not be replied to.