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)
Question
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?
Solution
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)