title: Rails - caching and permission based views
body: <p>I use CanCan to check user permissions and display or suppress page content conditionally for my users. I want to cache my pages though, and even with fragment caching can't find an elegant solution... for example:</p>
  
  <pre><code>cache do
  
  # much code
  
    if can?
      # little code
    else
      # little code
  
  # much code
  
    if can?
      # little code
    else
      # little code
  
  # much code
  </code></pre>
  
  <p>Surely I'm not alone and there's a good way to do this. What is generally considered the best practice here?</p>
  
  <p>Thanks very much for your input.</p>