|
|
@@ -9,6 +9,8 @@ class Product < ActiveRecord::Base
|
|
|
after_create :after_create
|
|
|
#after_update :after_update
|
|
|
before_save :before_save
|
|
|
+ after_destroy :del_picture
|
|
|
+
|
|
|
def after_create
|
|
|
#主商品默认关联商品
|
|
|
if self.show_flag
|
|
|
@@ -22,6 +24,17 @@ class Product < ActiveRecord::Base
|
|
|
self.relate_product_id = self.id
|
|
|
end
|
|
|
end
|
|
|
+
|
|
|
+ def del_picture
|
|
|
+ # 删除商品图片
|
|
|
+ pictures = ProductPicture.find_by_sql("select * from product_pictures where pic_type=0 and product_id = #{self.id}")
|
|
|
+ # 创建商品图片
|
|
|
+ pictures.each do |u|
|
|
|
+ u.remove
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
TYPE_ENUM = [["直营","direct_sale"]]
|
|
|
#["代销","user_sale"]
|
|
|
SIZE_ENUM = []
|