Reputation: 593
I have added a attribute to admin user, which is called hostel_name
. Now the Hostel is a upper most model in hierarchy and contains just only one attribute which is hostel_name(same as active admin model). This means all models are related to that model somehow.
Now I want the active admins to view just only their hostel's data. How can I do that in active admin?
Upvotes: 0
Views: 364
Reputation: 641
You can use active admin scopes : here's the doc : http://activeadmin.info/docs/2-resource-customization.html#scoping-the-queries I think it would be something like this
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
Upvotes: 0