Nischay Namdev
Nischay Namdev

Reputation: 593

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

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

Answers (1)

Nathan Schwarz
Nathan Schwarz

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

Related Questions