ruby on rails - Whats wrong with this else if statement? -
Actually my controller is now grabbing all the members: @ members = member All and Im checks by checking them by looping them whether they have uploaded the profile picture and if not, the default should be loaded:
;% @ members.each Do Members | & Gt%; & Lt;% Unless that member.image.nil? & Gt%; & Lt; Li style = "float: left; width: 100px;" & Gt; & Lt;% = image_tag (member.image.url (small))% & gt; & Lt;% = link_to member.email, member_path (member)% & gt; & Lt; / Li & gt; & Lt;% else% & gt; & Lt; Li style = "float: left; width: 100px;" & Gt; & Lt;% = image_tag ("default_member_small.jpg")%> & Lt;% = link_to member.email, member_path (member)% & gt; & Lt; / Li & gt; & Lt;% end% & gt; & Lt;% end% & gt; It seems that each member has a profile image, and the image tag is saying "images / small / missing.png" for missing images.
What gives?
I think you are using paperclip, if you are, then you Zero? , you should use Present : & lt;% @ members.each do | Members | & Gt%; & Lt;% if member.image.present? & Gt%; & Lt; Li style = "float: left; width: 100px;" & Gt; & Lt;% = image_tag (member.image.url (small))% & gt; & Lt;% = link_to member.email, member_path (member)% & gt; & Lt; / Li & gt; & Lt;% else% & gt; & Lt; Li style = "float: left; width: 100px;" & Gt; & Lt;% = image_tag ("default_member_small.jpg")%> & Lt;% = link_to member.email, member_path (member)% & gt; & Lt; / Li & gt; & Lt;% end% & gt; & Lt;% end% & gt; And if you should put it in the name of this clip, instead of expecting a paperclip, there should be no IFS in your code for such handling.
Comments
Post a Comment