Home>

I am implementing an edit page (edit action) for a site where you can list items.
Multiple images (image models) can be registered for products (product models), and images models are nested.
When accessing the edit page, the registered image is displayed in the form, and the saved image is displayed. Even if the image is not changed, the value is set in image_url when the update button is pressed. The following error will be displayed without.
ActiveRecord :: NotNullViolation in ProductsController # update
Error screen
https://gyazo.com/19831190041103672cdd7c656d281304

I use carrierwave to upload images

Probably, the image part is not correctly specified by the strong parameter of the controller.

.new-conteiner
  = render 'shared/new_header'
  .new-main
    .new-main__box
      % h2 Enter product information
      = form_for @product do | f |
        .image
          % h4 exhibition image
          .image__images

            = f.fields_for: images do | image |
              .image__images__box {"data-image-id": "# {image.object.id}"}
                = image.file_field: image_url, class: "file-field", style: "display: none;", id: "edit-file", value: "# {image.object.image_url.url}"
                = image_tag (image.object.image_url.url, id: "product_image", height: '120', width: '120')
                = image.hidden_field: id, value: image.object.id
                .edit_btns
                  .change_btn
                    .change_btn-text edit
                  .delete_btn
                    .delete_btn-text delete
def edit
    @product = Product.find (params [: id])
    @user = current_user
    @images = Image.where (product_id: @product)
    @category_parent_array = ["---"]
    Category.where (ancestry: nil) .each do | parent |
      @category_parent_array<<parent.name
    end
  end
def update
    if @ product.update (product_params)
      redirect_to product_path
    else
      render 'buyer_show'
    end
  end
private
  def product_params
    params.require (: product) .permit (
      : title,: image,: text,: price,: saler_id, {categories: []},
      images_attributes: [: image_url,: id],-# It seems that this part is not specified correctly
      condition_attributes: [: condition],
      freight_attributes: [: freight],
      root_area_attributes: [: root_area],
      day_attributes: [: day]
class Product
class Image