Too many pages using kaminari gem in Ruby on Rails 3.1 application
I am using the kaminari pagination gem in my simple Rails 3.1 application. Problem is it creates too many pages, I end up with completly blank pages at the end of my page list.
I have experimented in the console with:
current_user.articles
Which returns me a list of 6 articles, the same as the ones being displayed in my applicat开发者_JAVA技巧ion.
current_user.articles.count
Which returns me "8", is it this number that the number of pages is based on?
current_user.articles.length
Returns me "6"
current_user.articles.size
Returns me "8"
Is this discrepency between the number of articles causing my problem? Where is the problem, and how do I fix it please?
It's a bug, solution is here.
I guess your User#articles
is not just an ordinal has_many
, so we need a bit more info to see what's actually happening.
Could you show us current_user.articles.scoped.to_sql
?
精彩评论