abiao лет назад: 4
Родитель
Сommit
ea019926c6
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      app/models/product.rb

+ 7 - 1
app/models/product.rb

@@ -15,8 +15,14 @@ class Product < ActiveRecord::Base
             #主商品默认关联商品
             if self.show_flag
                 self.relate_product_id = self.id
-                self.save
             end
+
+            prd = Product.where("id = ?", self.relate_product_id).first
+            if prd.blank?
+                self.relate_product_id = self.id
+            end
+
+            self.save
         end
     end
     attr_accessor :v_share_img,:get_size_enum,:get_color_enum,:gross_interest_rate