This is what I did from my point of view:
<% if !(@attachment.attachment.content_type =~ /^image/).nil? %>
<%= image_tag @attachment.attachment.url(:small) %>
<%end%>
This assumes that your model is an attachment, and my file, I am the so-called attachment.
So you can do something like:
<% if !(@attachment.attachment.content_type =~ /^image/).nil? %>
<%= image_tag @attachment.attachment.url(:small) %>
<%else%>
<%= image_tag "/path/to/image/default.png" %>
<%end%>
source
share