# Undefined methods page\_count

**URL:** <https://www.ruby-forum.com/t/undefined-methods-page-count/122023>\
**Category:** Rails\
**Created:** [December 3, 2007, 10:48pm UTC](https://www.ruby-forum.com/t/undefined-methods-page-count/122023 "2007-12-03T22:48:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![christian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b2d939/32.png) [@christian](https://www.ruby-forum.com/u/christian)\
**Post date:** [December 3, 2007, 10:48pm UTC](https://www.ruby-forum.com/t/undefined-methods-page-count/122023/1 "2007-12-03T22:48:21Z")

</div>

I’m getting “undefined method `page\_count’ for #Array:0xb7073e1c”  
when I tried to run my rails application after installing  
will\_paginate. Details are as below:

undefined method `page\_count’ for #Array:0xb7073e1c

Extracted source (around line #7):

4: \<%= a.text%\>  
5: \<% end %\>  
6:  
7: \<%= will\_paginate @announcements, :inner\_window =\>  
10, :outer\_window =\> 10 %\>  
8:  
9:

10: \<%= link\_to\_protected ‘Main page’, :action =\> ‘index’ %\>

RAILS\_ROOT: ./script/…/config/…  
Application Trace | Framework Trace | Full Trace

/home/jerry/NetBeansProjects/hacdb/vendor/plugins/will\_paginate/lib/  
will\_paginate/view\_helpers.rb:45:in `will_paginate' /home/jerry/NetBeansProjects/hacdb/app/views/main/list_all_ann.rhtml: 7:in`\_run\_rhtml\_47app47views47main47list\_all\_ann46rhtml’

/home/jerry/NetBeansProjects/hacdb/vendor/plugins/will\_paginate/lib/  
will\_paginate/view\_helpers.rb:45:in `will_paginate' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_view/ base.rb:325:in`send’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_view/  
base.rb:325:in `compile_and_render_template' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_view/ base.rb:301:in`render\_template’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_view/  
base.rb:260:in `render_file' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/base.rb:812:in`render\_file’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/base.rb:717:in `render_with_no_layout' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/layout.rb:247:in`render\_without\_benchmark’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/benchmarking.rb:50:in `render' /usr/local/lib/ruby/1.8/benchmark.rb:293:in`measure’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/benchmarking.rb:50:in `render' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/base.rb:1102:in`perform\_action\_without\_filters’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/filters.rb:696:in `call_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/filters.rb:688:in`perform\_action\_without\_benchmark’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' /usr/local/lib/ruby/1.8/benchmark.rb:293:in`measure’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/rescue.rb:83:in`perform\_action’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/base.rb:435:in `send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/base.rb:435:in`process\_without\_filters’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/filters.rb:684:in  
`process_without_session_management_support' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/session_management.rb:114:in`process’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/base.rb:334:in `process' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:41:in`dispatch’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/rails.rb:  
76:in `process' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/rails.rb: 74:in`synchronize’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/rails.rb:  
74:in `process' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:155:in`process\_client’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:154:in  
`each' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:154:in`process\_client’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in  
`run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in`initialize’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in  
`new' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in`run’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in  
`initialize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in`new’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in  
`run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/ configurator.rb:282:in`run’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/  
configurator.rb:281:in `each' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/ configurator.rb:281:in`run’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/mongrel\_rails:  
128:in `run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/command.rb: 212:in`run’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/mongrel\_rails:281  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/  
active\_support/dependencies.rb:488:in `load' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:488:in`load’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/  
active\_support/dependencies.rb:342:in `new_constants_in' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:488:in`load’  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/commands/servers/  
mongrel.rb:60  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/  
active\_support/dependencies.rb:495:in `require' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:342:in`new\_constants\_in’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/  
active\_support/dependencies.rb:495:in `require' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/commands/server.rb: 39 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`gem\_original\_require’  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require’  
script/server:3

/home/jerry/NetBeansProjects/hacdb/vendor/plugins/will\_paginate/lib/  
will\_paginate/view\_helpers.rb:45:in `will_paginate' /home/jerry/NetBeansProjects/hacdb/app/views/main/list_all_ann.rhtml: 7:in`\_run\_rhtml\_47app47views47main47list\_all\_ann46rhtml’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_view/  
base.rb:325:in `send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_view/ base.rb:325:in`compile\_and\_render\_template’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_view/  
base.rb:301:in `render_template' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_view/ base.rb:260:in`render\_file’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/base.rb:812:in `render_file' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/base.rb:717:in`render\_with\_no\_layout’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/layout.rb:247:in `render_without_benchmark' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/benchmarking.rb:50:in`render’  
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/benchmarking.rb:50:in`render’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/base.rb:1102:in `perform_action_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/filters.rb:696:in`call\_filters’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/filters.rb:688:in `perform_action_without_benchmark' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/benchmarking.rb:66:in`perform\_action\_without\_rescue’  
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/benchmarking.rb:66:in`perform\_action\_without\_rescue’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/rescue.rb:83:in `perform_action' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/base.rb:435:in`send’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/base.rb:435:in `process_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/filters.rb:684:in`process\_without\_session\_management\_support’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/  
action\_controller/session\_management.rb:114:in `process' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/ action_controller/base.rb:334:in`process’  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:41:in  
`dispatch' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/rails.rb: 76:in`process’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/rails.rb:  
74:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/rails.rb: 74:in`process’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:155:in  
`process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:154:in`each’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:154:in  
`process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in`run’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in  
`initialize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in`new’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in  
`run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in`initialize’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in  
`new' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in`run’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/  
configurator.rb:282:in `run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/ configurator.rb:281:in`each’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/  
configurator.rb:281:in `run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/mongrel_rails: 128:in`run’  
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/command.rb:  
212:in `run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/mongrel_rails:281 /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:488:in`load’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/  
active\_support/dependencies.rb:488:in `load' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:342:in`new\_constants\_in’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/  
active\_support/dependencies.rb:488:in `load' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/commands/servers/ mongrel.rb:60 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`gem\_original\_require’  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:495:in`require’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/  
active\_support/dependencies.rb:342:in `new_constants_in' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:495:in`require’  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/commands/server.rb:  
39  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
script/server:3

I’m new to rails. Pleas help.

---

<div class="post-metadata">

**Author:** ![christian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b2d939/32.png) [@christian](https://www.ruby-forum.com/u/christian)\
**Post date:** [December 19, 2007, 2:34pm UTC](https://www.ruby-forum.com/t/undefined-methods-page-count/122023/2 "2007-12-19T14:34:07Z")

</div>

I’m having the same problem…  
I already know what is the problem but I don’t know how to solve it  
because I’m calling the pagination on one model (where I’m searching  
for something) but I’m showing results of another model that are  
linked to the first one.

```
            specs = Spec.paginate (:all, :page =>

```

params[:page], :per\_page =\> 10,  
:conditions =\> [“last\_name LIKE ?”,  
@initial+"%"],  
:order =\> “last\_name, first\_name”)  
@users = specs.collect { |spec| spec.user }

\<% if @users and not @users.empty? %\>

 \<% @users.each do |user| %\> \<% end %\> \<% will\_paginate @users %\> 

| Name | Age | Gender | Location |
| --- | --- | --- | --- |
| \<%= link\_to user.name, profile\_for(user) %\> | \<%= user.spec.age %\> | \<%= user.spec.gender %\> | \<%= user.spec.location %\> |

\<% end %\>

It’s returning page\_count undefined which I can understand but how do  
I paginate my @users array?

Thanks,  
Thiago G.
