소스 검색

增加复制商品功能

abiao 5 년 전
부모
커밋
0c163b29af
1개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 4 4
      app/models/product.rb

+ 4 - 4
app/models/product.rb

@@ -7,7 +7,8 @@ class Product < ActiveRecord::Base
     attr_accessor :v_share_img,:get_size_enum,:gross_interest_rate
     after_find :get_size_enum
     after_create :after_create
-    after_update :after_update
+    #after_update :after_update
+    before_save :before_save
     def after_create
         #主商品默认关联商品
         if self.show_flag
@@ -15,11 +16,10 @@ class Product < ActiveRecord::Base
             self.save
         end
     end
-    def after_update
-        #若取消,则用户卡次数加1
+    def before_save
+        #主商品默认关联商品
         if self.show_flag
             self.relate_product_id = self.id
-            self.save
         end
     end
     TYPE_ENUM = [["直营","direct_sale"]]