【发布时间】:2023-03-22 13:04:01
【问题描述】:
尝试使用 dropzone 保存一组图像而无需迭代。我切换到迭代图像并尝试保存循环。但是铁轨会吐
ActiveRecord::StatementInvalid 在 /products ============================================> SQLite3::ConstraintException: NOT NULL 约束失败: images.product_id: INSERT INTO "images" ("created_at", "ifoto", “product_data_id”、“product_id”、“updated_at”)值(?,?,?,?,?) 应用程序/控制器/products_controller.rb,第 214 行 ------------------------------------------------ @987654321 @App 回溯 ------------- - 应用程序/控制器/products_controller.rb:214:in
block (3 levels) in create' - app/controllers/products_controller.rb:211:inblock (2 级别)在创建' - app/controllers/products_controller.rb:137:in `create' 完整的回溯 --
这里是放置区代码
format.json do
@product = current_vitrine.products.build(params[:product])
@image = @product.images.build(params[:images])
if params[:images] && params[:images][:ifoto]
params[:images][:ifoto].values.each do |ifoto|
@image.ifoto = ifoto
@image.save
end
render :nothing => true
end
end
有人对这类问题有提示吗?
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4