Hello,
I have the following issue. When I try to output model records, I want to exclude records with 'dismiss'-field equal 'FALSE'. How could I do this? Is it possible without 'default_scope'?
My code example:
ActiveAdmin.register Approval do
index do
column :id
column 'Пользователя', :user
column 'Заапрувил член клуба', :member
column :dismiss
default_actions
end
end
You can override scoped_collection
method in your resource controller to fetch resources with custom query.
ActiveAdmin.register Approval do
index do
column :id
column 'Пользователя', :user
column 'Заапрувил член клуба', :member
column :dismiss
default_actions
end
def scoped_collection
Approval.where(dismiss: false) # this could be **Approval.dismissed**
end
end
I've tried to override scoped_collection in the way you wrote. But All the records are still output. Here is the query forming as a result:
where Approval Load (0.2ms) SELECT "approvals".* FROM "approvals" ORDER BY "approvals"."id" desc LIMIT 30 OFFSET 0
Tnx. Solution:
ActiveAdmin.register Approval do
index do
column :id
column 'Пользователя', :user
column 'Заапрувил член клуба', :member
default_actions
end
controller do
def scoped_collection
Approval.where(dismiss: false)
end
end
end
Most helpful comment
Tnx. Solution: