Active Admin pagination for array on custom page

Viewed 1400

Im working on a custom active admin page that has a query to pull all records from two models in Rails and show them in most recent order. As a result, I get an array back.

Using that, Im trying to paginate it on the custom made page in active admin, that was made using their register_page method.

Relevant code for register_page

ActiveAdmin.register_page "Bookings" do

 content do
   table_for(((StudentAvailableSlot.all + StudentClass.all).sort_by {|obj| obj.created_at}).reverse!, class: 'index_table') do
     #Display the information
   end

I cannot get ActiveAdmin to paginate the query and I've tried to get round it doing the following.

  1. Using Kaminari's paginate_array method but get this error: undefined method `except' for Kaminari::PaginatableArray
  2. Using active_record_union to maintain the ActiveRecord Relation class but it returned an array too.
  3. Creating a new model that could query both models and return a single collection with ActiveRecord Relation still available. I havent figured out how I would do this.

Any help would be greatly appreciated.

0 Answers
Related