title: How do I check to see if a model has a photo with Carrierwave?
body: <p>I have a model - <code>Post</code> - that can have images &amp; files uploaded to them. Two different uploaders in Carrierwave.</p>
  
  <p>What I want to do is, do a simple check for the presence of a photo upload on an object and if it is detected I will display the image tag. But if it isn't, then it shows nothing.</p>
  
  <p>I tried this:</p>
  
  <pre><code>&lt;% if post.photo %&gt;
      &lt;%= image_tag post.photo, size: "52", :class =&gt; 'entry-avatar' %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>But that doesn't work, it always shows this:</p>
  
  <pre><code>&lt;img class="entry-avatar" height="52" src width="52"&gt;
  </code></pre>
  
  <p>When it isn't blank, it adds the file path, correctly, to the <code>src</code> attribute.</p>
  
  <p>If I try to check for <code>photo.nil?</code> it doesn't work, even though it seems like it should:</p>
  
  <pre><code> &gt; a 
   =&gt; #&lt;Post id: 1, title: "Fire at Bible College in Christian", photo: nil, body: "A massive fire is now raging at the Bible College ...", created_at: "2014-08-28 08:06:19", updated_at: "2014-09-18 23:35:04", user_id: 1, ancestry: nil, file: nil, status: nil, slug: "fire-at-bible-college-in-christian", publication_status: 1, has_eyewitness: true&gt; 
  </code></pre>
  
  <p>Notice that the <code>:photo</code> attribute above is set to <code>nil</code>...yet when I do this:</p>
  
  <pre><code> &gt; a.photo
   =&gt; #&lt;PhotoUploader:0x00000102e19878 @model=#&lt;Post id: 1, title: "Fire at Bible College in Christian", photo: nil, body: "A massive fire is now raging at the Bible College ...", created_at: "2014-08-28 08:06:19", updated_at: "2014-09-18 23:35:04", user_id: 1, ancestry: nil, file: nil, status: nil, slug: "fire-at-bible-college-in-christian", publication_status: 1, has_eyewitness: true&gt;, @mounted_as=:photo&gt; 
   &gt; a.photo.nil?
   =&gt; false 
  </code></pre>
  
  <p>It doesn't work. </p>
  
  <p>Is there a Carrierwave method that I can use to do this or some other way?</p>