title: undefined method `[]' for nil:NilClass with rails params
body: <p>I have the following code:</p>
  
  <pre><code>&lt;% if params %&gt;
      &lt;% puts 'user params are' + params['user'].inspect.to_s %&gt;
             &lt;% if params['user']['type'] == 'Student' %&gt;
                &lt;div class="signup-popup-bg-failure sign-freelancer"&gt;&lt;% puts 'opt1stud' %&gt;
            &lt;% else%&gt;
                &lt;div class="signup-popup-bg sign-freelancer"&gt;&lt;% puts 'opt2stud'%&gt;
            &lt;% end %&gt;
  &lt;% else %&gt;
      &lt;div class="signup-popup-bg sign-freelancer"&gt;&lt;% puts 'opt3stud'%&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>This returns the error:</p>
  
  <pre><code>undefined method `[]' for nil:NilClass
  </code></pre>
  
  <p>and the line </p>
  
  <pre><code>&lt;% if params['user']['type'] == 'Student' %&gt;
  </code></pre>
  
  <p>is highlighted.</p>
  
  <p>I am trying to change what css class gets displayed depending on the params. </p>
  
  <p><br>if </p>
  
  <pre><code>params['type']['student'] 
  </code></pre>
  
  <p>exists, I want the class to be:</p>
  
  <pre><code>&lt;div class="signup-popup-bg-failure sign-freelancer"&gt;
  </code></pre>
  
  <p><Br>
  If</p>
  
  <pre><code>params['type']['Employer'] 
  </code></pre>
  
  <p>exists, I want the class to be:</p>
  
  <pre><code>&lt;div class="signup-popup-bg-failure sign-freelancer"&gt;
  </code></pre>
  
  <p>If there are no params, I want the class to be </p>
  
  <pre><code> &lt;div class="signup-popup-bg sign-freelancer"&gt;
  </code></pre>
  
  <p>I don't understand why this error exists.  The page says there are no params, so this code should not even be executed.  What's even stranger is that none of the 'puts' statements are getting executed.  This does not make sense either because the if/else logic dictate that one of the puts statements must be getting executed.  Does anyone know how to get this code to work? </p>