2013-05-21 33 views
0

我在附加图像上使用回形针以在我的导轨应用程序中提供。代码在开发过程中工作,但不在分期阶段。在分期中,图像正确保存到s3,但image_file_name为零。保存图像但使用回形针丢失的图像

DB /迁移/ 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

回答