# Will\_paginate wont\_paginate for me!

**URL:** <https://www.ruby-forum.com/t/will-paginate-wont-paginate-for-me/124021>\
**Category:** Rails\
**Created:** [December 23, 2007, 6:01pm UTC](https://www.ruby-forum.com/t/will-paginate-wont-paginate-for-me/124021 "2007-12-23T18:01:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![agorilla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@agorilla](https://www.ruby-forum.com/u/agorilla)\
**Post date:** [December 23, 2007, 6:01pm UTC](https://www.ruby-forum.com/t/will-paginate-wont-paginate-for-me/124021/1 "2007-12-23T18:01:09Z")

</div>

Sorry for the cheesy topic name couldn’t resist.

B4 I go into details I’m rocking Rails 1.2.6. I’m hosting on MediaTemple  
and they seem to working on some issue between their grid servers and  
2.0.

I’m struggling with pagination. I spent a few hours discovering that  
everyone thinks you should use a plugin to do your paginations. It seems  
will\_paginate is popular so I settled on that. It seems to have  
installed just fine - all the files are there and there was no errors.  
However, when I insert the code it doesn’t seem to like it.

I’m new to rails so I’m sure I’ve just overlooked something simple - if  
someone can help I’d be very grateful.

in my controller I have the following code

class ThumbController \< ApplicationController

model :thumb

def list  
@thumbs = Thumb.paginate :page =\> params[:page], :per\_page =\> 15  
end

end

In my list view I have the following (btw this works fine with my simple  
“@thumbs = Thumb.find(:all)” I had in my old controller.)

```
  <% for thumb in @thumbs %><a href="<%= thumb.url %>"><img

```

src="/images/thumbs/\<%= thumb.filename %\>" target="\_blank" alt=" "  
border=“0” /\>\<% end %\>

\<%= will\_paginate @thumbs %\>

As I say, I’ve probably just missed something dumb, but no matter how  
many tutorials or examples I go through I can’t seem to figure what it  
is ☹

Thanks in advance to some kind soul 🙂

---

<div class="post-metadata">

**Author:** ![agorilla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@agorilla](https://www.ruby-forum.com/u/agorilla)\
**Post date:** [December 23, 2007, 7:05pm UTC](https://www.ruby-forum.com/t/will-paginate-wont-paginate-for-me/124021/2 "2007-12-23T19:05:24Z")

</div>

Did you look at:

> **[\#51 will\_paginate - RailsCasts](http://railscasts.com/episodes/51-will-paginate)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

This helps alot as the main will\_paginate site doesn’t seem to work.

Jon

On Dec 23, 2007 9:01 AM, Bill G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![agorilla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@agorilla](https://www.ruby-forum.com/u/agorilla)\
**Post date:** [December 23, 2007, 7:16pm UTC](https://www.ruby-forum.com/t/will-paginate-wont-paginate-for-me/124021/3 "2007-12-23T19:16:21Z")

</div>

Hi Jon

Yeah, I checked this out.

It helped me set it up tho - the special conditions this guy uses threw  
me a little. I was hoping what I’m trying to set up is simpler.

Once I get it to work this cast will really help me to move the code  
into the model.

Cheers

ps - cool name, is that a typo?

Jon G. wrote:

> Did you look at:  
> [#51 will\_paginate - RailsCasts](http://railscasts.com/episodes/51)
> 
> This helps alot as the main will\_paginate site doesn’t seem to work.
> 
> Jon
> 
> On Dec 23, 2007 9:01 AM, Bill G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![agorilla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@agorilla](https://www.ruby-forum.com/u/agorilla)\
**Post date:** [December 23, 2007, 8:33pm UTC](https://www.ruby-forum.com/t/will-paginate-wont-paginate-for-me/124021/4 "2007-12-23T20:33:59Z")

</div>

Do you have more than 15 thumbnail images?  
If not, just set the :per\_page down to 1 or 2 and see it begins to  
work.  
If you have no images don’t expect much;-)

fredistic

---

<div class="post-metadata">

**Author:** ![agorilla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@agorilla](https://www.ruby-forum.com/u/agorilla)\
**Post date:** [December 23, 2007, 9:33pm UTC](https://www.ruby-forum.com/t/will-paginate-wont-paginate-for-me/124021/5 "2007-12-23T21:33:15Z")

</div>

When trying to figure out what could be your problem with  
will\_paginate I come to conclusion that something is fishy with your  
Thumb model.  
If Thumb.find(:all) is working than the only reason that will\_paginate  
won’t perform should be that limit-offset query that is used is  
returning empty record set.  
You should look development log file for SQL statements that are  
performed and you will find the way to the solution.

If you can be more specific than, perhaps, we can help you even more.

On Dec 23, 8:59 pm, Bill G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![agorilla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@agorilla](https://www.ruby-forum.com/u/agorilla)\
**Post date:** [December 23, 2007, 8:59pm UTC](https://www.ruby-forum.com/t/will-paginate-wont-paginate-for-me/124021/6 "2007-12-23T20:59:17Z")

</div>

haha yeah, i wish it was that simple - there’s about 25 images in there.

as I said when I display all without the Will\_paginate they display  
fine.

i’m wondering if will\_paginate is note working on the server - does  
anyone know a simple way for me to test? Though, even more likely is I  
screwed up in my code 😉

fredistic wrote:

> Do you have more than 15 thumbnail images?  
> If not, just set the :per\_page down to 1 or 2 and see it begins to  
> work.  
> If you have no images don’t expect much;-)
> 
> fredistic

---

<div class="post-metadata">

**Author:** ![agorilla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@agorilla](https://www.ruby-forum.com/u/agorilla)\
**Post date:** [December 29, 2007, 3:55pm UTC](https://www.ruby-forum.com/t/will-paginate-wont-paginate-for-me/124021/7 "2007-12-29T15:55:52Z")

</div>

Dejan D. wrote:

> When trying to figure out what could be your problem with  
> will\_paginate I come to conclusion that something is fishy with your  
> Thumb model.

Here is the content of thumb.rb

class Thumb \< ActiveRecord::Base  
end

As you can see I added nothing here - could this be the issue?

> If Thumb.find(:all) is working than the only reason that will\_paginate  
> won’t perform should be that limit-offset query that is used is  
> returning empty record set.  
> You should look development log file for SQL statements that are  
> performed and you will find the way to the solution.

Great idea to check out the logs - below seems to be the errors  
generated when I try and access the page with the will\_paginate  
included.

Thanks a lot for your input.

Processing ApplicationController#list (for 85.27.49.251 at 2007-12-29  
06:43:55) [GET]  
Session ID: 145bc5e03a9492916fa16a2edcc15faf  
Parameters: {“action”=\>“list”, “controller”=\>“thumb”}

LoadError (Expected  
/home/15922/containers/rails/gggallery/app/controllers/thumb\_controller.rb  
to define ThumbController):  
/home/15922/data/rubygems/gems/gems/activesupport-1.4.4/lib/active\_support/dependencies.rb:249:in  
`load_missing_constant' /home/15922/data/rubygems/gems/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:452:in`const\_missing’  
/home/15922/data/rubygems/gems/gems/activesupport-1.4.4/lib/active\_support/dependencies.rb:464:in  
`const_missing' /home/15922/data/rubygems/gems/gems/activesupport-1.4.4/lib/active_support/inflector.rb:250:in`constantize’  
/home/15922/data/rubygems/gems/gems/activesupport-1.4.4/lib/active\_support/core\_ext/string/inflections.rb:148:in  
`constantize' /home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action_controller/routing.rb:1317:in`recognize’  
/home/15922/data/rubygems/gems/gems/rails-1.2.6/lib/dispatcher.rb:40:in  
`dispatch' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/../lib/mongrel/rails.rb:76:in`process’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/…/lib/mongrel/rails.rb:74:in  
`synchronize' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/../lib/mongrel/rails.rb:74:in`process’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/…/lib/mongrel.rb:155:in  
`process_client' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/../lib/mongrel.rb:154:in`each’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/…/lib/mongrel.rb:154:in  
`process_client' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/../lib/mongrel.rb:281:in`run’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/…/lib/mongrel.rb:281:in  
`initialize' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/../lib/mongrel.rb:281:in`new’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/…/lib/mongrel.rb:281:in  
`run' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/../lib/mongrel.rb:264:in`initialize’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/…/lib/mongrel.rb:264:in  
`new' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/../lib/mongrel.rb:264:in`run’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/…/lib/mongrel/configurator.rb:282:in  
`run' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/../lib/mongrel/configurator.rb:281:in`each’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/…/lib/mongrel/configurator.rb:281:in  
`run' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/mongrel_rails:128:in`run’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/…/lib/mongrel/command.rb:212:in  
`run’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/mongrel\_rails:281

---

<div class="post-metadata">

**Author:** ![agorilla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@agorilla](https://www.ruby-forum.com/u/agorilla)\
**Post date:** [December 29, 2007, 4:53pm UTC](https://www.ruby-forum.com/t/will-paginate-wont-paginate-for-me/124021/8 "2007-12-29T16:53:18Z")

</div>

Hi

I rebuilt the page the way it was - ie without will\_paginate. It worked  
fine as before and generated no errors in the log. Then I reverted to  
include will\_paginate. Now I get an error different to the log above. I  
also restarted my application.

* * *

Processing ThumbController#list (for 85.27.49.251 at 2007-12-29  
07:11:20) [GET]  
Session ID: 145bc5e03a9492916fa16a2edcc15faf  
Parameters: {“action”=\>“list”, “controller”=\>“thumb”}  
Rendering within layouts/application  
Rendering thumb/list

ActionView::TemplateError (undefined method `page_count' for #<Array:0xb75e3bcc>) on line #22 of app/views/thumb/list.rhtml: 19: <div id="rightNav"></div> 20: 21: </div> 22: <%= will_paginate @thumbs %> /home/15922/containers/rails/gggallery/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb:45:in`will\_paginate’  
/home/15922/containers/rails/gggallery/app/views/thumb/list.rhtml:22:in  
`_run_rhtml_47app47views47thumb47list46rhtml' /home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action_view/base.rb:325:in`send’  
/home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action\_view/base.rb:325:in  
`compile_and_render_template' /home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action_view/base.rb:301:in`render\_template’  
/home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action\_view/base.rb:260:in  
`render_file' /home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action_controller/base.rb:812:in`render\_file’  
/home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action\_controller/base.rb:717:in  
`render_with_no_layout' /home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action_controller/layout.rb:247:in`render\_without\_benchmark’  
/home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action\_controller/benchmarking.rb:50:in  
`render' /usr/lib/ruby/1.8/benchmark.rb:293:in`measure’  
/home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action\_controller/benchmarking.rb:50:in  
`render' /home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action_controller/base.rb:1102:in`perform\_action\_without\_filters’  
/home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action\_controller/filters.rb:696:in  
`call_filters' /home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action_controller/filters.rb:688:in`perform\_action\_without\_benchmark’  
/home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' /usr/lib/ruby/1.8/benchmark.rb:293:in`measure’  
/home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' /home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action_controller/rescue.rb:83:in`perform\_action’  
/home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action\_controller/base.rb:435:in  
`send' /home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action_controller/base.rb:435:in`process\_without\_filters’  
/home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action\_controller/filters.rb:684:in  
`process_without_session_management_support' /home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action_controller/session_management.rb:114:in`process’  
/home/15922/data/rubygems/gems/gems/actionpack-1.13.6/lib/action\_controller/base.rb:334:in  
`process' /home/15922/data/rubygems/gems/gems/rails-1.2.6/lib/dispatcher.rb:41:in`dispatch’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel/rails.rb:76:in  
`process' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel/rails.rb:74:in`synchronize’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel/rails.rb:74:in  
`process' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel.rb:155:in`process\_client’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel.rb:154:in  
`each' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel.rb:154:in`process\_client’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel.rb:281:in  
`run' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel.rb:281:in`initialize’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel.rb:281:in  
`new' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel.rb:281:in`run’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel.rb:264:in  
`initialize' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel.rb:264:in`new’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel.rb:264:in  
`run' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel/configurator.rb:282:in`run’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel/configurator.rb:281:in  
`each' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel/configurator.rb:281:in`run’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/mongrel\_rails:128:in  
`run' /home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/lib/mongrel/command.rb:212:in`run’  
/home/15922/data/rubygems/gems/gems/mongrel-1.1.1-i386-linux/bin/mongrel\_rails:281

---

<div class="post-metadata">

**Author:** ![agorilla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@agorilla](https://www.ruby-forum.com/u/agorilla)\
**Post date:** [December 29, 2007, 11:41pm UTC](https://www.ruby-forum.com/t/will-paginate-wont-paginate-for-me/124021/9 "2007-12-29T23:41:16Z")

</div>

Yay, I fixed it 🙂

Dejan was right, there was something fishy in my model - ie nothing!

Thanks to this post - [I Will Paginate — err.the\_blog](http://errtheblog.com/posts/47-i-will-paginate)

I found that I needed the following code in my thumb.rb.

cattr\_reader :per\_page  
@@per\_page = 15

Thanks for the pointer.
