title: HAML Check for Null
body: <p>Working on a learning management system. NOT a RoR person. Have the line of HAML to generate an average score based on quizzes taken:</p>
  
  <pre><code>="#{(QuizResult.average('score', :conditions =&gt; "user_id = #{@user.id}") * 100).round}%"
  </code></pre>
  
  <p>The quiz_results table has columns for used_id and score.</p>
  
  <p>However, if there are no records in the quiz_results table, the page doesn't render. I want to check if any scores exist for that user id, and if so, to show the average. If none exist, I want to display "No quizzes taken." here's what I have:</p>
  
  <pre><code>19:             %td
  20:                 -if QuizResult('score', :conditions =&gt; "user_id = #{@user.id}").exists?
  21:                     ="#{(QuizResult.average('score', :conditions =&gt; "user_id = #{@user.id}") * 100).round}%"
  22:                 -else
  23:                     %em No quizzes taken
  </code></pre>
  
  <p>I get the following error:</p>
  
  <p>"ActionView::TemplateError (undefined method `QuizResult' for #ActionView::Base:0x7028c7f5cb88>) on line #20 of app/views/manage_users/show_all_users.haml:"</p>
  
  <p>I've been struggling all day with this. Any suggestions? Thanks in advance, from an RoR noob.</p>