Explorar el Código

model add scope

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

+ 5 - 1
app/models/product.rb

@@ -121,6 +121,7 @@ class Product < ActiveRecord::Base
         if self.buy_price != 0 && self.price != 0
             rate = (( self.price.to_f - self.buy_price.to_f )/self.buy_price.to_f)*100
         end
+
         return rate
     end
 
@@ -129,8 +130,11 @@ class Product < ActiveRecord::Base
         weight -240
 
         list do
+            current_user.id
+            if current_user.id==1
+                scopes [:inactive]
+            end
 
-            scopes [:inactive]
             filters [:id,:detail,:status,:name]
 
             field :id