undefined method `total_pages' for nil:NilClass
mhartl opened this issue · comments
Michael Hartl commented
I get the error undefined method 'total_pages' for nil:NilClass
when leaving off an explicit argument to will_paginate
. In other words, if @users
contains a (paginated) list of users on the Users index page, the code
<%= will_paginate(@users) %>
works fine, but the equivalent code
<%= will_paginate %>
raises the error above.
I'm considering bootstrap-will_paginate
for inclusion in the Ruby on Rails Tutorial, 2nd Edition, so it would be awesome if you could fix this issue, for the sake of newbies everywhere.
Nicholas Fine commented
Ah, I've not used the simplified syntax before. I'll take a look at this today. Thanks for the report!
Nicholas Fine commented
That should do it.
Amrit Deep Dhungana commented
I got the same error.