In Kaminari, this works:
<%= paginate @posts %>
But if I do something like:
<%= paginate @user.posts %>
I get
undefined method `current_page' for #<Class:0x58378e0>
How do I fix this? I heard inherited_resources helped, but I don’t know how to use it to fix this bug.
Because in the first version
@postswas probably the result of running something likeSo Kaminari returned an array like object, which
paginatehelper method expects.When you call
@user.postsdirectly you are in fact just loading a plain old ActiveRecord association.The short answer is that you need to let Kaminari generate the variable you are in fact using with the
paginatehelper method