Explorar el Código

model add scope

abiao hace 5 años
padre
commit
f66413f1a0
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      app/models/product.rb

+ 3 - 1
app/models/product.rb

@@ -2,6 +2,8 @@
 class Product < ActiveRecord::Base
     has_paper_trail
     self.table_name = 'products'
+    before_filter :authenticate_admin_user!
+
     scope :active, -> { where(ptype: "cent_sale") }
     scope :inactive, -> { where(ptype: "direct_sale") }
     belongs_to :product_cat, :foreign_key => :category_id
@@ -121,7 +123,7 @@ class Product < ActiveRecord::Base
             rate = (( self.price.to_f - self.buy_price.to_f )/self.buy_price.to_f)*100
         end 
             #return ((rate*100).round.to_f/100).to_s + "%"
-            user= RailsAdmin.config.admin_user
+            user= admin_user
         return user
     end