Spencer Hire Spencer Hire - 1 year ago 191
Ruby Question

ActionController::RoutingError (No route matches [GET] "/images/medium/missing.png"):

This problem is - i think - pointing to a deleted image, but there is definitely no image called

in the app.

ActionController::RoutingError (No route matches [GET] "/images/medium/missing.png"):

Prefix Verb URI Pattern Controller#Action
pins GET /pins(.:format) pins#index
POST /pins(.:format) pins#create
new_pin GET /pins/new(.:format) pins#new
edit_pin GET /pins/:id/edit(.:format) pins#edit
pin GET /pins/:id(.:format) pins#show
PATCH /pins/:id(.:format) pins#update
PUT /pins/:id(.:format) pins#update
DELETE /pins/:id(.:format) pins#destroy
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PATCH /users/password(.:format) devise/passwords#update
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PATCH /users(.:format) devise/registrations#update
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
root GET / pages#home
about GET /about(.:format) pages#about

Answer Source

but there is definitely no image called missing in the app.

... and that is the problem!

Your app is looking for a picture to show, if no image has been uploaded.
This is defined in your model, where the attachment (via paperclip or carrierwave) is defined.

see the Quick Start of e.g. paperclip

class User < ActiveRecord::Base
  has_attached_file :avatar, 
    :styles => { :medium => "300x300>", :thumb => "100x100>" }, 
    :default_url => "/images/:style/missing.png" # <= you see ?

You need to place an image called missing.png for each different style (here medium and thumb) defined in your app/assets/images/:style folder(s). This will then be handled by the asset pipeline. If you only want to upload the missing-images to S3, you need to define a bucket there, add folders for each defined style and reference them via absolute path like this:

:default_url => "https://YOURBUCKET.amazons3.com/:style/missing.png"

If you upload all your user uploaded content to S3, i recommend reading the excellent documentation on Paperclip::Storage::S3.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download