will_paginate generates undefined method paginate

Dear

I used to use the will_paginate plugin, and now it is no longer available in the repository.

I am using the one in the gem #gem install will_paginate

in my controller I have this

@careers = Career.paginate :page => params[:page], :per_page => 10

and in the view

<%= will_paginate @careers %>

I found this way in all the tutorials and the railscasts episode 51. Though I still receive the error undefined method paginate

I have googled it but I did not get the answer

any idea???

thanks

Have you got at the bottom of your environment.rb file the line:

require ‘will_paginate’

I think this is needed because you’re using the gem version, when I believe the screencast is for the old plugin version (I’ll have to double check that, but its sounds like thats the case).

Regards Kieran

Hi

Thanks for the reply I did add the require 'will_paginate' and it is not working

I receive this error

undefined method `paginate' for #<Class:0x2c18b24>

RAILS_ROOT: D:/ubaida/depot_r Application Trace | Framework Trace | Full Trace

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ base.rb:1667:in `method_missing' app/controllers/admin_controller.rb:12:in `list'

As for the cast, yes it is the old plugin and it is not available as well. Any alternative

I also have troubles with will_paginate

It seems will_paginate have a large bug

What version of will_paginate are you using?

Older versions are broken on 2.1 and you should install the latest
version: sudo gem install mislav-will_paginate -s http://gems.github.com

Then put require ‘will_paginate’ in an initializer or in
environment.rb (you need to have added vendor/gems to load path
already to do that).

(check this post for more details Gotchas When Upgrading to Rails 2.1)

Best. Mike

I have version 2.2.2

What version of rails? if you're using 2.1 I believe you need to get
will_paginate version 2.3.

I have installed version 2.3 following the tutorial and I still face the same issue

I have installed version 2.3 following the tutorial and I still face the same issue

I had exactly the same problem, but I resolved by putting “require will_paginate” on the last line of the of the environment.rb. Before I had it in the beginning of the file, and I received the same error you did. Not sure why it has to be on the bottom of the file, maybe someone can explain.

Cheers,

Aaron

No after installing and adding to environment.rb file still getting the same error...

Shuaib85

I have been usisng will_paginate and it seems to work fine. In the railscast episode 51 I believe the code for the pagination was put in the model - moved from the controller. Have you tried this? Also I notice that on your previous post it said that your undifined method was in your list action on line 12. perhaps you could show more of your code and also paste your question on the will_paginate google group where the author of the code often helps. I am a newb so I don't know if this will help Best of sucess. - Owen

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ base.rb:1667:in `method_missing' app/controllers/admin_controller.rb:12:in `list'

I found an easy solution to this problem... Stop the WEbrick server and start it again...

Seems dumb I know, but I was using the method where you modify config/ environment.rb to include this line: <code> config.gem 'mislav-will_paginate', :version => '~> 2.3.4', :lib => 'will_paginate', :source => 'http://gems.github.com'</

it should go right after the: <code>Rails::Initializer.run do |config| </code> line

then you perform <code>sudo rake gems:install</code> and it installs the gem for you. But it was giving me this error message unti I stopped the WEbrick server and started it again.

Go Figure...

Aaron Feng wrote:

I have installed version 2.3 following the tutorial and I still face the same issue

I had exactly the same problem, but I resolved by putting "require will_paginate" on the _last_ line of the of the environment.rb. Before I had it in the beginning of the file, and I received the same error you did. Not sure why it has to be on the bottom of the file, maybe someone can explain.

Cheers,

Aaron

WoW!

Don't know why, but it works here too on mislav-will_paginate (2.3.11)

Thank you!

hqmq wrote:

I found an easy solution to this problem... Stop the WEbrick server and start it again...

Yeah I fix it :smiley: 10x

Without your answer, I would probably have witch-hunted forever... Thanks

hqmq wrote in post #731654:

you can replace .paginate by .send(:paginate) to cheat it ...