ActionController :: RoutingError(没有路线匹配[GET]“/images/medium/missing.png”): [英] ActionController::RoutingError (No route matches [GET] "/images/medium/missing.png"):

查看:191
本文介绍了ActionController :: RoutingError(没有路线匹配[GET]“/images/medium/missing.png”):的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是 - 我认为 - 指向一个已删除的图像,但在应用程序中绝对没有图像称为缺少

  ActionController :: RoutingError(没有路由匹配[GET]/images/medium/missing.png):

前缀动词URI模式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(.:格式)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)设计/注册#new
edit_user_r egistration 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
GET GET / pages#home
GET /about(.:format)pages#about

解决方案



...那就是问题所在!



您的应用正在寻找一张图片来显示,如果没有图像上传。

这是在您的模型中定义的,其中定义了附件(通过回形针或carrierwave)。



请参阅快速入门 回形针

  class User< ActiveRecord :: Base 
has_attached_file:头像,
:styles => {:medium => 300x300>,:thumb => 100×100> 中},
:default_url => /images/:style/missing.png#< =你看到了吗?
end

您需要放置名为的图片missing.png 为每个不同的风格(这里 medium thumb )在 app / assets / images /:style 文件夹中定义。这将由资产管道处理。
如果您只想将缺失 -images上传到S3,则需要在那里定义一个存储桶,为每个定义的样式添加文件夹并通过像这样的绝对路径引用它们:

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

如果您上传所有用户上传的内容到S3,我推荐阅读 Paperclip :: Storage :: S3


This problem is - i think - pointing to a deleted image, but there is definitely no image called missing 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

解决方案

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 ?
end

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.

这篇关于ActionController :: RoutingError(没有路线匹配[GET]“/images/medium/missing.png”):的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆