Reputation: 2282
<%- if @last_msg.photo? -%>
<%= image_tag @last_msg.photo.url(:listsize) %>
<%- else -%>
<%= image_tag("default.jpg") %>
<%- end -%>
Currently this returns either the photo from the last message or a default image, but when a new user creates an account there is no @last_msg so I get a nomethoderror. How can I put in another if statement to say that if there is no last message, then the default image will be returned? Thanks.
Upvotes: 0
Views: 958