瀏覽代碼

model add scope

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

+ 4 - 3
app/models/product.rb

@@ -125,15 +125,16 @@ 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
+            def current_user
+                @current_user ||= AdminUser.find_by(id: session[:user_id])
+            end
+
             if current_user.id==1
                 scopes [:inactive]
             end