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

+ 3 - 1
app/models/product.rb

@@ -1,6 +1,8 @@
 class Product < ActiveRecord::Base
     has_paper_trail
     self.table_name = 'products'
+    scope :active, -> { where(ptype: "cent_sale") }
+    scope :inactive, -> { where(ptype: "direct_sale") }
     belongs_to :product_cat, :foreign_key => :category_id
     belongs_to :merchant, :foreign_key => :merchant_id
     validates :name,:buy_price,:price,:category_id,:count,:robo_balance_price, presence: true
@@ -126,7 +128,7 @@ class Product < ActiveRecord::Base
         weight -240
 
         list do
-            scopes [ptype, "direct_sale"]
+            scopes [:active]
 
             filters [:id,:detail,:status,:name]