簡體   English   中英

如何在Active Admin:Rails中為管理員賦予不同的訪問級別?

[英]How to give different access levels to admins in Active Admin:Rails?

我向管理員用戶添加了一個屬性,稱為hostel_name 現在,旅館是層次結構中最高級的模型,並且僅包含一個屬性hostel_name(與活動管理員模型相同)。 這意味着所有模型都以某種方式與該模型相關。

現在,我希望活動管理員僅查看其旅館的數據。 如何在活動管理員中執行此操作?

您可以使用活動的管理范圍:這是文檔: http : //activeadmin.info/docs/2-resource-customization.html#scoping-the-queries我認為這會是這樣的

ActiveAdmin.register Hostel do
  scope_to :current_user # limits the accessible Hostel to `current_user.hostels`


  # Finally, you can pass a block to be called:
  scope_to do
    User.hostel_name
  end
end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM