【发布时间】:2013-05-30 03:41:16
【问题描述】:
我在我的 rails 应用程序中使用回形针将图像附加到优惠。该代码在开发中有效,但在暂存中无效。在暂存中,图像正确保存到 s3,但 image_file_name 为 nil。
db/migrate/20130507182116_add_image_to_offers.rb
class AddImageToOffers < ActiveRecord::Migration
def self.up
add_attachment :offers, :image
end
def self.down
remove_attachment :offers, :image
end
end
app/models/offer.rb
class Offer < ActiveRecord::Base
attr_accessor :image
has_attached_file :image, styles: {
thumb: '100x100>',
square: '200x200#',
medium: '300x300>'
}
当我在开发模式下运行以下配置时,它可以工作,当我切换到暂存时,我收到以下错误:
Paperclip::Error (Offer model missing required attr_accessor for 'image_file_name'):
如果我将attr_accessor :image_file_name添加到它完成的模型并将图像保存到s3,但数据库中的属性是nil。
【问题讨论】: