will_paginate: undefined method `total_pages' for #
Hi Mislav, I got error in my project with will_paginate, i used rails 4 , active record 4, and will_paginate 3.0.7
in my controller @users=User.paginate(:page => params[:page], :per_page => 30)
in my view <%= will_paginate @users %>
always give error undefined method `total_pages’ for #User::ActiveRecord_Relation:0x000000051b4608
how to solve it,? Thanks
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 16 (1 by maintainers)
Commits related to this issue
- Fix #411: ensure returned collection is a WillPaginate::Collection. — committed to pathwaysmedical/will_paginate by dhMuse 7 years ago
- Fix #411: ensure returned collection is a WillPaginate::Collection. — committed to pathwaysmedical/will_paginate by dhMuse 7 years ago
I got this error, too. But I figured out I forgot to use
paginatein my controller.Still getting this problem in a new application. Initially I was only getting it with blank results, as had been asserted. But even after populating the database and having an Active Record Relation with multiple entries the same error is being generated. It seems like the Relation is not being handled by will_paginate’s model tweaking for Rails.
The problem for me was that
will_paginatein the view is being passed an un-paginated collectionI had a conditional that added pagination
Got rid of my conditional and it’s fine now