Reputation: 2889
I have this piece of code that doesn't seem to work for a strange reason:
<% if (@user.photo.blank?) %>
<%= image_tag("empty_profile_pic.png") %> <!-- replace with user's image -->
<%else %>
<%= image_tag(@user.photo.url(:small)) %>
<% end %>
If the picture is null in the mySQL database I want it to display another pic.
I have tried, empty?, nil?, blank?
but with no success, and also
@user.photo.blank.url.*
Any help?
Upvotes: 0
Views: 53
Reputation: 3766
<%= image_tag(@user.photo.try(:url, :small) || "empty_profile_pic.png") %>
Upvotes: 1