20

I am currently using paperclip to upload images to my rails app. This is probably a very simple fix but how or where do I save the missing images to? This is the error that is produced from not having any missing images. How do I change this?

ActionController::RoutingError (No route matches "/photos/normal/missing.png"):
morcutt
  • 3,739
  • 8
  • 30
  • 47

1 Answers1

40

If you don't need any control over the default image, which I don't think you need, you can place it in any folder under RAILS_ROOT/public/images/

Just make sure you point it out in the attachment model with the :default_url parameter. So for example if you place the image in RAILS_ROOT/public/images/normal/missing.png you need t specify the path like this:

has_attached_file :photo, :default_url => "/images/normal/missing.png"
Kick Buttowski
  • 6,709
  • 13
  • 37
  • 58
DanneManne
  • 21,107
  • 5
  • 57
  • 58
  • quick fix! is there anyway to designate which missing image to use for each style. For instance, I save each image as a thumbnail as 50x50 and I save each "normal" picture as 110x110. Can I save two different images for each use? – morcutt Nov 24 '10 at 08:08
  • 5
    You could specify the :default_url parameter like "/images/:style/missing.png" or perhaps "/images/missing/:style.png" – DanneManne Nov 24 '10 at 10:29
  • BTW, Paperclip looks into public/images/:style/missing.png by default when it cannot find an image. So if you need one default image to be displayed for all of your models that have attached file - just place corresponding style image into folder I mentioned. For example, for 'large' style you'd need to put default missing.png into public/images/large/ – Yaro Holodiuk May 25 '15 at 09:45