Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kaminari: undefined method `total_pages' for Array

Using Rails & Kaminari gem, I am getting the below error when I render my view:

undefined method `total_pages' for #Array:0x007faa486583e0

controller:

def index
    @user = current_shop.users.new
    @users = current_shop.active_users   ### This returns an array
    Kaminari.paginate_array(@users).page(params[:page]).per(10)
 end

view:

     <tbody>
       <%= paginate @users %>

        <% @users.each do |user| %>
          <%= render 'user_table_row', :user=> user %>
       <% end %>

     </tbody>

What am I doing wrong?

like image 570
Jackson Cunningham Avatar asked Oct 02 '15 16:10

Jackson Cunningham


1 Answers

I think you have to assign

@users = Kaminari.paginate_array(@users).page(params[:page]).per(10)

in your controller.

like image 188
Krisdigital Avatar answered Nov 05 '22 00:11

Krisdigital