I am a little late in discussion but I've the solution to the problem :)

If you are using rails 4 then try this.

@users = User.all.paginate(page: params[:page]

Note that User.all will be an ActiveRelation on which paginate method works.

If you are using rails 3 then try this.

@users = User.where('').paginate(page: params[:page])

The reason to use an empty where is because where will return the
ActiveRelation which is more efficient instead of loading an array using

Note that User.all will return ActiveRelation in rails 4 and in rails 3 it
will return an Array.
On Friday, October 25, 2013 1:47:19 AM UTC+5, desbest wrote:

I'm getting a undefined method `paginate' for #<Class:0x567eb98> even
though I have gem 'will_paginate' installed.
Inside the users_controller I have @users = User.paginate(page: params[
so I believe I set everything up to be correct.
Can you figure out why the method's undefined, despite installing the gem?
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2390d463-501b-4ed3-8c26-2448d2b05544%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 7 | next ›
Discussion Overview
grouprubyonrails-talk @
postedOct 24, '13 at 8:47p
activeOct 27, '13 at 4:16a



site design / logo © 2021 Grokbase