admin how to display only the current

Using rails_admin let's assume we have 3 users and 10 stores.

The first user has role == 'root' and the other 2 users have role == 'admin' .

There is a typical rails has_and_belongs_to_many relationship successfully established between User and Store .

When any User accesses the rails_admin engine /admin , I'd like that User to be able to access any Store that they are associated with or in the case of the role == 'root' User, they should be able to access all the Stores.

I'm digging through the rails admin wiki and I'm not really seeing anything that would give me this ability.

I'm thinking there is a customization somewhere that would display only stores that the current_user has as relations (or whatever other conditions I specify).

Any thoughts here?

Thanks,

JD


Use cancancan with rails_admin: https://github.com/CanCanCommunity/cancancan/wiki/Ability-Precedence

Your example going to be resolved with:

can :manage, Store do |store|
  store.users.include? current_user
end
链接地址: http://www.djcxy.com/p/67064.html

上一篇: 在轨道上订购协会

下一篇: 管理员如何只显示当前