rdp / substruct

Automatically exported from code.google.com/p/substruct
0 stars 0 forks source link

doesn't set rank for new images #231

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. upload an image
2. detect the newly uploaded image's product_image rank -- it's nil

Original issue reported on code.google.com by freeldss...@gmail.com on 14 Mar 2014 at 1:24

GoogleCodeExporter commented 9 years ago
diff --git a/app/controllers/admin/products_controller.rb 
b/app/controllers/admin/products_controller.rb
index 0bcd19b..962ea23 100644
--- a/app/controllers/admin/products_controller.rb
+++ b/app/controllers/admin/products_controller.rb
@@ -264,6 +264,9 @@ class Admin::ProductsController < Admin::BaseController
             new_image.uploaded_data = i[:image_data]
             if new_image.save
               @product.images << new_image
+              product_image = new_image.reload.product_images[0]
+              product_image.rank = @product.reload.next_image_rank_to_use 
+              product_image.save
             else
               image_errors.push(new_image.filename + " " +  new_image.errors.map{|e| e.to_s}.join(' '))
             end

perhaps? (see other patches on the ML FWIW) :)

Original comment by rogerpack2005 on 14 Mar 2014 at 1:54