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

I use carrierwave to upload images

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

  = render 'shared/new_header'
      % h2 Enter product information
      = form_for @product do | f |
          % h4 exhibition image

            = 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
                    .change_btn-text edit
                    .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 |
def update
    if @ product.update (product_params)
      redirect_to product_path
      render 'buyer_show'
  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