title: Providing context to user index results
body: <p>In my Rails 3 app I have an index of users that I filter using checkboxes. I'd like to provide some context to the results of the filtering. Say if I check hometown, I'd like to provide some dialog that says "20 people are from your hometown" or something. Is there a way to do this that is pretty easy to grasp?</p>
  
  <p>I know enough to return the number of users each search renders with <code>&lt;%= @users.count %&gt;</code>, but how can I add the context depending on the search parameters?</p>
  
  <p>Here's an example of my code:</p>
  
  <pre><code>&lt;%= search_form_for @q, :url =&gt; search_users_path, :html =&gt; {:method =&gt; :post} do |f| %&gt;
    &lt;table id="careerCriteria"&gt;
      &lt;tr&gt;
        &lt;td class="head"&gt;Hometown:&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td class="normal"&gt;&lt;%= current_user.profile.hometown %&gt;&lt;/td&gt;
        &lt;td class="check"&gt;&lt;%= f.check_box :profile_hometown_cont, {}, "#{current_user.profile.high_school}", '' %&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;% end %&gt;
  &lt;% @users.each do |user| %&gt;
  &lt;div class="userSnapshot"&gt;
  ...
  &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>