defcreate@product=Product.new(product_params)if@product.save(validate: false)redirect_toproducts_path,notice: "#{@product.name} has been created."elserender'new'endenddefupdate@product=Product.find(params[:id])@product.attributes=product_paramsif@product.save(validate: false)redirect_toproducts_path,notice: "The product \"#{@product.name}\" has been updated. "elserender'edit'endend
defcreate@product=Product.new(product_params)@product.skip_name_validation=trueif@product.saveredirect_toproducts_path,notice: "#{@product.name} has been created."elserender'new'endenddefupdate@product=Product.find(params[:id])@product.attributes=product_params@product.skip_price_validation=trueif@product.saveredirect_toproducts_path,notice: "The product \"#{@product.name}\" has been updated. "elserender'edit'endend