Kaminari & Rails pagination – undefined method `current_page’
Try with: def show @topic = Topic.find(params[:id]) @posts = @topic.posts.page(params[:page]).per(2) end And then: <%= paginate @posts %>
Try with: def show @topic = Topic.find(params[:id]) @posts = @topic.posts.page(params[:page]).per(2) end And then: <%= paginate @posts %>
See https://github.com/mislav/will_paginate/blob/master/lib/will_paginate/array.rb Just require ‘will_paginate/array’ before you try it and it will work just fine. If it were me, I’d put that in say config/initalizers/will_paginate_extensions.rb so it’s available right away and from everywhere.
This is the only available helper method to paginate an array object using Kaminari. Another alternative is, as suggested solution in kaminari wiki page, add the instance methods to the array object. If you are trying a common solution based on the ActiveModel return type ( .all returns array and .where returns ARL) then following … Read more
As mentioned in the question, you can get the total count of the records with @users.total_count I’ve added this as an answer for the sake of completeness.