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 ?