开发者

Paperclip avatars image missing if user didnt uploaded image

开发者 https://www.devze.com 2023-02-16 03:33 出处:网络
I am using Paperclip for uploading the Profile image in my application (rails) My User model is having a

I am using Paperclip for uploading the Profile image in my application (rails)

My User model is having a

 has_attached_file :avatar,
   :url => "/:attachment/:id/:style/:basename.:extension",
   :path => ":ra开发者_如何学JAVAils_root/public/:attachment/:id/:style/:basename.:extension",
   :styles => { :medium => "300x300>", :small => "100x100>", :thumb => "50x50>", :micro => "30x30>" }

In my VIew If i have a profile image uploaded then its pointing correctly as

/avatars/1/thumb/iamge

BUt if the image is not there if they didn't uploaded in that case its pointing as

/avatars/thumb/missing.png which doesn't have any image.

Please give suggestions what to do if the user didnt uploaded any profile image..


You can make a default image and put it there and name it missing.png. It is like extra functionality :)

0

精彩评论

暂无评论...
验证码 换一张
取 消