【问题标题】:Paperclip - No route matches GET回形针 - 没有路线匹配 GET
【发布时间】:2012-09-15 12:25:11
【问题描述】:

回形针 2.7 Ruby 1.8.7 企业版 导轨 3.1.0 Imagemagick 6.6

当我在我的应用程序中上传图像时,它们会被 imagemagick 正确处理,并且它们存储在正确的路径中。但是,当我需要拿这个文件来显示时,却找不到。

保存图片:

Started POST "/p" for 177.16.57.105 at Sun Sep 23 23:39:16 -0300 2012
Processing by ProductsController#create as HTML
Parameters: {"commit"=>"Salvar", "authenticity_token"=>"EgBUGfKIIduS2lkl0mh5p27pT0vF0/P8HXO852KHMM8=", "utf8"=>"â", "product"=>{"photo"=>#>, "price"=>"", "name"=>"Brigadeiro de pistache", "product_type"=>"1", "featured"=>"0", "description"=>"Brigadeiro de pistache"}}
[32mCommand[0m :: convert '/tmp/stream20120923-19588-vw8u1s-020120923-19588-3lym39-0[0]' -resize "120x80>" '/tmp/stream20120923-19588-vw8u1s-020120923-19588-3lym39-020120923-19588-16ky3i8-0'
[paperclip] Saving attachments.
[paperclip] saving /home/brigaderiagourmand/apps_rails/site/public/system/photos/24/short/brigadeirocolorido.png
Redirected to http://brigaderiagourmand.com.br/p/24
Completed 302 Found in 257ms

当我需要文件时...

Started GET "/photos/original/missing.png" for 177.16.57.105 at Sun Sep 23 23:39:17 -0300 2012

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

我的模型

class Product < ActiveRecord::Base
  attr_accessible :name, :description, :price, :photo, :product_type, :featured
  attr_accessor :photo_file_name
  has_attached_file :photo, :styles => { :thumb => "50x50>", :medium => "280x180>", :large => "585x400>", :short => "120x80>", :original => "200,200>" }

  TYPES = ["Belga", "Normal"]
end

表单视图

= form_for @product, :html => {:multipart => true} do |f|
  = f.file_field :photo

显示视图

= image_tag @product.photo.url(:original)

【问题讨论】:

    标签: ruby-on-rails upload routes paperclip


    【解决方案1】:

    处理图像的输出是否完整? 在您的输出回形针中,仅将大小重新调整为短(120x80>)

    您的 get 请求正在尝试加载 missing.jpg,如果无法找到请求,这是图像的默认设置。查看 /home/brigaderiagourmand/apps_rails/site/public/system/photos/24/ 看看是否有其他调整大小的照片。

    Ryan Bates 对paperclip 进行了精彩的截屏视频

    希望对你有帮助

    【讨论】:

    • 谢谢@Flo,但我迁移到carrierwave :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-15
    • 2011-12-11
    • 2015-09-27
    • 2015-10-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多