I am building up an array of products in rails. Which is working fine, but my question is...
Is there any way to update an item if it exists in the array already? So as I am looping through products, and the model is "TV-32D300B" I need to check the array to see if it exists, but it may only be a partial number like "TV-32D300" (minus the last letter).
If the is the case I want to be able to update that product with the correct details.
product = {
name: product_name,
url: product_url,
modelnumber: product_modelnumber,
category_id: category.id,
group_id: category.group_id,
image_url: image_url
}
I'm using the include? to add products to the array if a product doesn't already exist, so I am guessing I need to add a like condition to find the number.
unless products.include?(product)
products << product
end
TV-32D300B, thenTV-32D300Wand finally haveTV-32D300.