2012-12-06 49 views
0

我已經在我的rails應用程序中安裝ActiveAdmin,並且不管理只顯示屬於索引頁面中登錄用戶的設備。ActiveAdmin:如何只在索引頁面中獲取current_user記錄

我有幾種模式:
- 用戶
- 組
- 設備

用戶 has_and_belongs_to_many
設備 has_and_belongs_to_many

當用戶登錄在,我' d只需要屬於索引中列出的用戶組之一的設備。

我想我activeadmin的設備模型中修改控制器:

controller do 
    def index 
    index! do |format| 
     @devices = current_user.is_admin? ? Device.all : current_user.groups.map{ |g| g.devices }.flatten.uniq 
     format.html 
    end 
    end 
end 

但我結束了以下錯誤:

未定義的方法`訂貨」的#

任何想法?

回答

相關問題