2016-06-03 3 views
0

이미지가 Paperclip으로 업로드되면 "Successfully Uploaded"와 같은 페이지에주의를 포함시킬 수있는 방법이 있습니까?이미지가 Paperclip으로 업로드 될 때 예고하는 방법

<div class="img-circle"> 
     <%= profile_avatar_select(@user) %> 
    </div> 
    <%= f.input :avatar, as: :file, label: "false" %> 
     </div> 

내 application_helper.rb

def profile_avatar_select(user) 
    return image_tag user.avatar.url(:medium), 
        id: 'image-preview', 
        class: 'img-responsive img-circle profile-image' if user.avatar.exists? 
    image_tag 'default-avatar.png', id: 'image-preview', 
            class: 'img-responsive img-circle profile-image' 
end 

및 user.rb의 :

has_attached_file :avatar, styles: { medium: '152x152#' } 
validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/ 
end 
+0

:'플래시 [: 성공] = "이미지 업로드"' – 7urkm3n

답변

1

아바타 업로드는 여기에 현재 코드가 내 간단한 양식의 일부입니다 application.html.erb

<% flash.each do |k,v| %> 
    <%= content_tag :div, v, class: "alert alert-#{k} text-center" %> 
<% end %> 

컨트롤러 컨트롤러

#in a method right above render or redirect 
flash[:success] = "Image Uploaded" 
+0

왜 당신이 파일을 로케일이 메시지를 넣어하지 않았습니다. –