0

this is my post_controller

def index
@posts = Post.all.page(params[:page]).per(2)


respond_to do |format|
  format.html # index.html.erb
  format.json { render json: @posts }
end
 end

this is /views/posts/index

<%= paginate @posts %>

and i recive:

NoMethodError in PostsController#index

undefined method `page' for #


I saw many themes with the same error and solution:

Kaminari.paginate_array(my_array_object).page(params[:page]).per(10)

but where should i put this?

1 Answers1

0

You can put it in your controller

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

But you also could do this:

@posts = Post.page(params[:page]).per(2)
sites
  • 21,417
  • 17
  • 87
  • 146
  • 2
    I get an undefined method "paginate_array" for Kaminari:module how to solve this? – Þaw Jan 29 '14 at 01:26