【发布时间】:2015-03-12 21:54:04
【问题描述】:
我正在尝试在创建新产品和使用 CarrierWave 上传/调整图像大小的过程中使用 DelayedJob 实现后台进程(全部在 save 方法中完成)
我有一个页面,摄影师可以在其中上传新图片以及标题、描述等。
直到所有内容都成功处理后,新记录才会保存,因此当我尝试在“@photo.delay.save”行延迟处理时出现错误
def create
@photo = Photo.new(photo_params)
if @photo.delay.save
flash[:notice] = "Your new photograph is being processed."
redirect_to @photo
else
flash[:notice] = "Please check that all the fields were entered"
render 'new'
end
结束
错误
job cannot be created for non-persisted record: #<Photo id: nil, title: "prod number 8526", created_at: nil, updated_at: nil, id_num: "jh878", year_taken: "2015", is_active: false, show_bw_conversion: false, format_id: 1, rotating_keyword: "picture", slug: nil, qty_sold: 0, photographer_id: 5, daily_deal: nil, default_mat: 1, default_frame: 1, description: "<p>This is the description3895</p>", qty_download: 0, film_type: "digital", image: nil>
这种策略是否可行,或者我应该让摄影师列出标题、描述等,以便干净地保存新记录,然后运行延迟作业以使用 Carrier Wave 上传/调整图像大小?
谢谢, 杰夫
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 carrierwave delayed-job