paperclip where to place the missing.png default image?

前端 未结 2 1682
日久生厌
日久生厌 2021-01-19 03:53

I use paperclip in my app, but my controller tests are failing because of:

BlogsControllerTest#test_should_update_blog:
Paperclip::AdapterRegistry::NoHandle         


        
2条回答
  •  梦谈多话
    2021-01-19 04:48

    In Rails 5, I managed to work using :style in the path:

    Paperclip::Attachment.default_options[:default_url] = "/images/folder/:style/missing.png"
    

    and if, for example, this image doesn't exist:

    <%= image_tag @photo.picture.url(:medium) %>
    

    the result is

    /images/folder/medium/missing.png
    

提交回复
热议问题