从早期版本升级到3.x(S3存储)后,回形针不生成缩略图/样式/尺寸

时间:2013-02-18 06:41:33

标签: ruby-on-rails paperclip

我为创建图像时创建的Paperclip gem定义的各种样式在升级后停止工作。这些文件根本没有创建,但“原始”是(唯一的)。

class Image < ActiveRecord::Base
  belongs_to  :member
  has_many    :article_images, :dependent => :destroy
  has_many    :articles, :through => :article_images

  has_many    :member_photos, :dependent => :destroy
  has_one     :member_avatar, :dependent => :destroy

  validates_presence_of :member_id

  after_validation do |resource| 
    #since paperclip doesn't give a damn error message like an idiot
    resource.errors[:image] = resource.errors[:image_file_name] ?  resource.errors[:image_file_name] : resource.errors[:image_content_type]
  end

  before_save do |resource| 
    #set name to filename if no name sent
    resource.name = resource.image_file_name.split('.')[0].titleize if resource.name.blank? 
  end

  scope :for_slideshow, limit(5) 

  has_attached_file :image, 
    :styles => { 
      :original    => "1100x1100", #overwrites orig, for file storage efficiency
      :x_large     => "900x900",
      :large       => "600x600",
      :medium      => "300x300>",
      :thumb_1     => "100x100#",
      :thumb_2     => "50x50#",
      :thumb_3     => "25x25#"
      #To refresh image thumbs: rake paperclip:refresh CLASS=Image
    },
    :storage => :s3,
    :path => ":attachment/:id/:style.:extension",
    :s3_credentials => "#{::Rails.root}/config/s3.yml"

    #:url => "/system/:attachment/:id/:style/:filename"


  validates_attachment_content_type :image, :content_type=>['image/jpeg', 'image/png', 'image/gif', 'image/pjpeg', 'image/x-png'] #last two for IE 6-8
  validates_attachment_presence :image
  #validates_attachment_size :image, :less_than=>1.megabyte

end

日志不再显示任何尝试:

  SQL (0.3ms)  INSERT INTO `images` (`caption`, `created_at`, `desc`, `image_content_type`, `image_file_name`, `image_file_size`, `image_updated_at`, `member_id`, `name`, `updated_at`) VALUES ('', '2013-02-18 06:34:55', '', 'image/jpeg', '525119_10151396740758260_611505697_n.jpeg', 111946, '2013-02-18 06:34:55', 719, '525119 10151396740758260 611505697 N', '2013-02-18 06:34:55')
[paperclip] Saving attachments.
[paperclip] saving images/4201/original.jpeg
[AWS S3 200 1.367095 0 retries] put_object(:acl=>:public_read,:bucket_name=>"mybucket.development/paperclip",:content_length=>111946,:content_type=>"image/jpeg",:data=>Paperclip::UploadedFileAdapter: 525119_10151396740758260_611505697_n.jpeg,:key=>"images/4201/original.jpeg")  

我错过了什么?

1 个答案:

答案 0 :(得分:0)

无论出于何种原因,降级到2.8已经“修复”了这个问题。但我想成为最新版本......