我正在使用回形针将图像附加到我的 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
应用程序/模型/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
在数据库中。