2012-06-08 2 views
0

나는 이상한 이유로 작동하지 않는 코드의이 작품이 : 그림이 내가 다른를 표시 할 MySQL 데이터베이스에 null의 경우레일 3

<% if (@user.photo.blank?) %>    
     <%= image_tag("empty_profile_pic.png") %> <!-- replace with user's image --> 
    <%else %> 
     <%= image_tag(@user.photo.url(:small)) %> 
    <% end %> 

을 사진. 나는 empty?, nil?, blank?하지만 성공, 또한

@user.photo.blank.url.* 

어떤 도움을 시도?

+0

당신은 이미지 처리를 위해 사용합니까 어떤 플러그인? Carrierwave? 잠자리? 클립? –

+0

종이 클립을 사용하고 있습니다 –

답변

1

어때 대략

@ user.photo.exists?

~ 찰스 ~

1
<%= image_tag(@user.photo.try(:url, :small) || "empty_profile_pic.png") %> 
+0

파일을 보았습니까? 그리고 일하는 것 같다. –