I have an application where you can fill in metadata of documents. I currently have a problem with the default filtering as it doesn't filter my index table. The filter options are shown on the right side and you can also see the filtering options in the url and params after you choose a filter and hit the button.
utf8=✓&q%5Buser_id_eq%5D=3&commit=Filter&order=id_desc
But somehow the index table doesn't refresh.
The only scope I have is the default:
scope :all, default: true
EDIT
I think it has something to do with the pagination because If i remove pagination the filters work again.
This is my current index method in my app/admin/DocumentType.rb file:
def index
index! do |format|
@document_types = DocumentType.where(archived_at: nil).page(params[:page])
file_name = "document_types_#{DateTime.now.strftime('%a_%d_%b_%Y_%H%M%S').downcase}"
format.xls {
spreadsheet = DocumentTypesSpreadsheet.new @document_types
send_data spreadsheet.generate_xls, filename: file_name + ".xls"
}
end
end
Only document types which are not archived should be displayed in the index therefore i have
@document_types = DocumentType.where(archived_at: nil).page(params[:page])
Now with this my filter don't work. But if I remove this line completely they work again except now it displays also the archived document types. And if I remove the .page(params[:page]) part I get the following error message:
Collection is not a paginated scope. Set collection.page(params[:page]).per(10) before calling :paginated_collection.