Displaying message if no photo present...

Posted by bgadoci on Stack Overflow See other posts from Stack Overflow or by bgadoci
Published on 2010-05-14T14:55:29Z Indexed on 2010/05/14 17:54 UTC
Read the original article Hit count: 198

I am using the code:

<%= image_tag site.photo.url(:small) if site.photo.file? %>

to tell my app to display nothing if there is no photo associated with a particular post (site in this case). Is there a way to render a message along w/ this. For instance "no image with the post". I tried simply doing

<%= if site.photo.file? %>
  <p> no image with this site </p>
<% end %> 

But that doesn't seem to work. New to ruby and rails if you can't tell.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby