2010-10-24 36 views
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它也不會工作

我收到以下錯誤

不能轉換成數組字符串

回答

0

我有同樣的問題,這是由於update到回形針。我很驚訝,heroku仍然使用這個寶石版本,因爲它肯定會影響所有的用戶;我安裝了以前的版本作爲插件,並沒有問題。不要忘記從.gems文件中移除寶石,或在寶石清單中指定以前的版本。