1
嗨香港專業教育學院得到了在我的模型下面的代碼Amazon S3的路徑或to_file不會工作
需要 'RMagick'
類上傳<的ActiveRecord :: Base的 belongs_to的:卡
has_attached_file :photo,
:styles => {
:thumb => ["100x100", :jpg],
:pagesize => ["500x400", :jpg],
},
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":attachment/:id/:style.:extension",
:bucket => 'your_deck',
:default_style => :pagesize
attr_accessor :x1, :y1, :width, :height
def update_attributes(att)
scaled_img = Magick::ImageList.new(self.photo.path)
orig_img = Magick::ImageList.new(self.photo.path(:original))
scale = orig_img.columns.to_f/scaled_img.columns
args = [ att[:x1], att[:y1], att[:width], att[:height] ]
args = args.collect { |a| a.to_i * scale }
orig_img.crop!(*args)
orig_img.write(self.photo.path(:original))
self.photo.reprocess!
self.save
super(att)
end
end
該代碼可以離線工作,但是當在Heroku上使用Amazon S3時,它無法工作,我嘗試使用to_file它也不會工作
我收到以下錯誤
不能轉換成數組字符串