Ruby on rails 回形针后处理转换不会更新文件名、内容和类型属性

Ruby on rails 回形针后处理转换不会更新文件名、内容和类型属性,ruby-on-rails,paperclip,imagemagick-convert,Ruby On Rails,Paperclip,Imagemagick Convert,我想将文件上传限制为只上传图像,并将它们自动转换为.png。为此,我使用以下类: class ImageAttachment < ActiveRecord::Base attr_accessible :file, :file_file_name, :file_content_type, :file_file_size validates_attachment :file, :content_type => { :content_type => ["image/

我想将文件上传限制为只上传图像,并将它们自动转换为.png。为此,我使用以下类:

class ImageAttachment < ActiveRecord::Base
  attr_accessible :file, :file_file_name, :file_content_type, :file_file_size

  validates_attachment :file,
    :content_type => { :content_type => ["image/jpg", "image/tiff", "image/png"] }

  has_attached_file :file,
    :styles      => { :original => ["100%", :png],
                      :large    => ["500x500", :png],
                      :medium   => ["150x150", :png],
                      :thumb    => ["75x100", :png]
                    },
    :default_url => "/system/missing_thumb.png"
end
第一个断言是真的,我还可以在终端中看到ImageMagick输出, 但是attachment.file\u file\u name仍然返回example.tiff,attachment.file\u content\u type返回image/tiff

我认为回形针会自动更新文件名和文件内容类型属性,这是错误的吗

如果是这样的话,我自己怎么做才是最好的

it "should convert all image types to .png" do
  test_file = File.new(Rails.root + "spec/fixtures/images/test.tiff")
  attachment = ImageAttachment.create :file => test_file
  attachment.file.url.should == "some/paperclip/path/.../test.png"
  attachment.file_file_name.should == "test.png"
  attachment.file_content_type.should == "image/png"
end