Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 回形针-更新数据库中存在但S3上不存在的附件_Ruby On Rails_Ruby_Amazon S3_Paperclip - Fatal编程技术网

Ruby on rails 回形针-更新数据库中存在但S3上不存在的附件

Ruby on rails 回形针-更新数据库中存在但S3上不存在的附件,ruby-on-rails,ruby,amazon-s3,paperclip,Ruby On Rails,Ruby,Amazon S3,Paperclip,这里我们有简单的rails模型: class Attachment < ActiveRecord::Base has_attached_file :attachment, styles: lambda { |attachment| store_sizes?(attachment) ? { :large => ["414x300>",:png], :medium => ["138x100>", :png], :fo

这里我们有简单的rails模型:

class Attachment < ActiveRecord::Base   
has_attached_file :attachment, styles: lambda { |attachment| 
    store_sizes?(attachment) ? { 
      :large => ["414x300>",:png],
      :medium => ["138x100>", :png],
      :for_index => ["180x100", :png],
      :for_preview => ["180x100", :png],
      :thumb => ["62x42>", :png],
      :approval => ['285x122#', :png],
      :origin_png => ['100%', :png]
    } : {}   },
    :storage => :s3,
    :s3_credentials => "#{Rails.root}/config/s3.yml",
    :s3_headers => {"Content-Disposition" => "attachment"}
这将返回类似以下内容的url:

因此,现在我想将我的文件放入附件属性:

 my_new_file = File.open('/tmp/somefile.jpg')
 a.attachment = my_new_file
 a.attachment.save
成功保存后,我检查了在amazon上创建的内容,我只有:原始样式。 问题是应该有:大、:中、:路径、:for_索引等样式

我试过了

 a.attachment.reprocess! 
但它忘记了所有的风格,只有:原创

如何在S3上更新文件时创建所有样式?


问题可以通过以下方式解决:

a.attachment.reprocess! 
但是在development.log中有一些关于ImageMagick版本的抱怨。 我已经更新了imagemagick,并且成功地重新处理了所有样式

有时候,写下你的问题来更好地理解问题是很好的:)

a.attachment.reprocess!