2

回形针 2.7 Ruby 1.8.7 企业 Rails 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)
4

1 回答 1

0

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

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

Ryan Bates 有一个很棒的关于回形针的截屏视频

希望这可以帮助你

于 2012-09-24T08:41:39.020 回答