Browse Source

model add scope

abiao 4 years ago
parent
commit
ac8535cfec
1 changed files with 4 additions and 1 deletions
  1. 4 1
      app/models/product.rb

+ 4 - 1
app/models/product.rb

@@ -125,12 +125,15 @@ class Product < ActiveRecord::Base
         return rate
     end
 
+    def current_user
+        @current_user ||= AdminUser.find_by(id: session[:user_id])
+    end
+
     rails_admin do 
         navigation_label '商品管理'
         weight -240
 
         list do
-            current_user.id
             if current_user.id==1
                 scopes [:inactive]
             end