當我意識到這對於其他人瞭解哪裏出了問題是有價值的時候,我正要刪除它。
所以,如果你按照教程去發球,你會做得很好。但是,如果您使用attr_accessible
來保護模型的屬性,則需要在模型中指定所有這些屬性,以便將這些圖像實際保存到S3存儲桶中。
有淡淡的將是,如果你看到你的日誌如下:
WARNING: Can't mass-assign protected attributes: photo
這可以讓你知道,你在你的數據庫需要通過attr_accessible
暴露這裏的保護欄如果您要按照我在我的問題中提供的示例教程,代碼的外觀如何:
class Product < ActiveRecord::Base
attr_accessible :photo, :photo_file_name, :photo_content_type, :photo_file_size, :photo_updated_at
belongs_to :page
has_attached_file :photo,
:styles =>{
:thumb => "100x100",
:medium => "200x200",
:large => "600x400"
},
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":attachment/:id/:style.:extension",
:bucket => 'yourbucket'
end
代碼+ l ogs請。 – jdl 2011-03-19 02:07:27