title: Ruby on rails: If else in controller issue
body: <p>So I am having an issue with an if else statement in the controller. I have 4 radiobuttons on my page and one hidden field. There are also 4 divs where only one can be visible at a time.When a different radiobutton is checked another div is shown. This should work like a 'complex' search interface. In the hidden field I'm inserting a value from 1 to 4 (depending on what radio button is checked). In the controller I'm looking at the value of the hidden field and my functions should change accordingly. My problem is that it does not work. I tried a couple of different things but didn't find an answer to my problem.</p>
  
  <p>Here's my code</p>
  
  <h2>View:</h2>
  
  <pre><code>&lt;div&gt;
      &lt;%= radio_button_tag 'searchRBN', 'patient', true, :onchange =&gt; "checkRadioButton()" %&gt;
      &lt;%= label_tag :byPatient_patient, "Patient" %&gt;
      &lt;%= radio_button_tag 'searchRBN', 'staff', false, :onchange =&gt; "checkRadioButton()" %&gt;
      &lt;%= label_tag :byStaff_staff, "Staff" %&gt;
      &lt;%= radio_button_tag 'searchRBN', 'ocmw', false, :onchange =&gt; "checkRadioButton()" %&gt;
      &lt;%= label_tag :byOcmw_ocmw, "OCMW" %&gt;
      &lt;%= radio_button_tag 'searchRBN', 'mutuality', false, :onchange =&gt; "checkRadioButton()" %&gt;
      &lt;%= label_tag :byMutuality_mutuality, "Mutuality" %&gt;
  &lt;/div&gt;
  &lt;%= hidden_field_tag(:hidden_one, "1") %&gt;
  &lt;div id="searchByPatient"&gt;
      &lt;%= form_tag patients_path, :method =&gt; 'get' do %&gt;
          &lt;p&gt;
              &lt;%= text_field_tag :search1, params[:search1] %&gt;
              &lt;%= submit_tag "Search", :name =&gt; nil %&gt;
          &lt;/p&gt;
      &lt;% end %&gt;
  &lt;/div&gt;
  
  &lt;div id="searchByStaff" class="notVisible"&gt;
      &lt;%= form_tag patients_path, :method =&gt; 'get' do %&gt;
          &lt;%= text_field_tag :search2, params[:search2] %&gt;
          &lt;%= submit_tag "Search", :name =&gt; nil %&gt;
      &lt;% end %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <h2>Controller:</h2>
  
  <pre><code>  def index
      @staff_all = Staff.all
      @ocmw_all = Ocmw.all
      @mutuality_all = Mutuality.all
  
      if params[:hidden_one] == '1'
        @patients = Patient.searchByName(params[:search1])
      elsif params[:hidden_one] == '2'
        @patients = Patient.searchByStaff(params[:search2])
      else
        @patients = Patient.all
      end
    end
  </code></pre>
  
  <h2>In my model:</h2>
  
  <pre><code>  def self.searchByName(search)
      if search
        find(:all, :conditions =&gt; ['name LIKE ?', "%#{search}%"])
      else
        find(:all)
      end
    end
  
    def self.searchByStaff(search)
      if search
        find(:all, :conditions =&gt; ['marriedTo LIKE ?', "%#{search}%"])
      else
        find(:all)
      end
    end
  </code></pre>
  
  <p>Mathias A.</p>