瀏覽代碼

model add scope

abiao 4 年之前
父節點
當前提交
48ea1cb2e5
共有 1 個文件被更改,包括 2 次插入4 次删除
  1. 2 4
      app/models/product.rb

+ 2 - 4
app/models/product.rb

@@ -2,7 +2,6 @@
 class Product < ActiveRecord::Base
     has_paper_trail
     self.table_name = 'products'
-    authorize! :index, @user, :message=> 'Not authorized as an administrator.'
 
     scope :active, -> { where(ptype: "cent_sale") }
     scope :inactive, -> { where(ptype: "direct_sale") }
@@ -123,8 +122,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= session_path(user_id)
-        return @user
+        return @current_user.email
     end
 
     rails_admin do 
@@ -132,7 +130,7 @@ class Product < ActiveRecord::Base
         weight -240
 
         list do
-            #authorize! :index, @user, :message=> 'Not authorized as an administrator.'
+            # authorize! :index, @user, :message=> 'Not authorized as an administrator.'
 
             scopes [:inactive]