0

I've install ActiveAdmin in my rails app and do not manage to only display devices that belongs to the logged in user in the index pages.

I have several models:
- user
- group
- device

user has_and_belongs_to_many groups
devices has_and_belongs_to_many groups

When a user is logged in, I'd only need the devices belonging to one of the user's groups listed in the index.

I tried to modify the controller within my activeadmin's device model:

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

but I end up with the following error:

undefined method `reorder' for #

Any idea ?

4

1 回答 1

0

I think, you should read this issue.

https://github.com/gregbell/active_admin/issues/1178

于 2012-12-06T12:55:46.823 回答