# Paginating\_find Help anyone

**URL:** <https://www.ruby-forum.com/t/paginating-find-help-anyone/143095>\
**Category:** Rails\
**Created:** [July 15, 2008, 6:55am UTC](https://www.ruby-forum.com/t/paginating-find-help-anyone/143095 "2008-07-15T06:55:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![THEBIGO](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea666f/32.png) [@THEBIGO](https://www.ruby-forum.com/u/THEBIGO)\
**Post date:** [July 15, 2008, 6:55am UTC](https://www.ruby-forum.com/t/paginating-find-help-anyone/143095/1 "2008-07-15T06:55:47Z")

</div>

Hello - I am using paginating\_find trying to paginate my records My  
CallsController index action is

def index  
@calls = @current\_user.calls.find(:all, :page =\> {:size =\>  
4, :current =\> params[:page]})  
end

then in the index template for the calls view I have

 \<% @current\_user.calls.each do |call| %\> 1. \<%= link\_to h(call.name), :action =\> 'show', :id =\> call %\>
 \<% end %\> 
 \<%= @calls %\> \<%= paginating\_links(@calls) %\>

I only have the \<%= @calls %\> to see what is in the @calls variable  
to see if it is available to paginating\_find but it isn’t. The  
each.do loop gives links to all the current\_user’s calls but I get no  
paginating. I would like 4 per page. If I change the loop to  
@calls.each do I get calls for all the users which is not what I want  
and if I change the paginating\_links to  
paginating\_links(@current\_user.calls) I get the following error

undefined method `page’ for #Class:0x251dacc

Extracted source (around line #16):

13: \<% end %\>  
14:   
15: \<%= @calls %\>  
16: \<%= paginating\_links(@current\_user.calls) %\>  
17:  
18:  
19:  
So my paginating\_links is getting nothing to paginate from what I can  
see althoug it doew list pages 1 and 2 as links  
Any help out there please

Owen

---

<div class="post-metadata">

**Author:** ![THEBIGO](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea666f/32.png) [@THEBIGO](https://www.ruby-forum.com/u/THEBIGO)\
**Post date:** [July 15, 2008, 2:50pm UTC](https://www.ruby-forum.com/t/paginating-find-help-anyone/143095/2 "2008-07-15T14:50:30Z")

</div>

So the problem is that @calls is not scoped to the @current\_user?

---

<div class="post-metadata">

**Author:** ![THEBIGO](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea666f/32.png) [@THEBIGO](https://www.ruby-forum.com/u/THEBIGO)\
**Post date:** [July 15, 2008, 3:27pm UTC](https://www.ruby-forum.com/t/paginating-find-help-anyone/143095/3 "2008-07-15T15:27:11Z")

</div>

Thank you so much for your reply Alexkwolf. Thants how I see it also  
When I change the line before \<%=  
paginating\_links(@current\_users.calls) %\>  
to \<%= @current\_user.calls %\> just to see what is in the variable i  
get the following

```
    <ol>

            <li><a href="/calls/142">Vanessa</a></li>

            <li><a href="/calls/168">Linnea</a></li>

            <li><a href="/calls/169">Richard</a></li>

            <li><a href="/calls/170">Linea</a></li>

            <li><a href="/calls/171">Mark</a></li>

            <li><a href="/calls/172">My friend</a></li>

            <li><a href="/calls/173">Melvin</a></li>

            <li><a href="/calls/174">Tuesday</a></li>

            <li><a href="/calls/175">Tony lynn</a></li>

            <li><a href="/calls/176">Lyn Lyn</a></li>

            <li><a href="/calls/177">Marjorie</a></li>

    </ol>
    #<Call:0x20f4b44>#<Call:0x20f4a54>#<Call:0x20f4950>#<Call:

```

0x20f4874\>#Call:0x20f4798#Call:0x20f46a8#Call:0x20f45b8#\<Call:  
0x20f44c8\>#Call:0x20f43ec#Call:0x20f4310#Call:0x20f4234

```
    1 <a href="/calls?page=2">2</a> <a href="/calls?page=3">3</a>

   and if I change the line before to just <%= @calls %> i get

```

this avter the loop output

 #

```
    1 <a href="/calls?page=2">2</a> <a href="/calls?page=3">3</a>

```

So I am not sure what is happening allthough both times I get this  
interesting output of numbers. Any idea would be greatly appreciated

Owen

On Jul 15, 5:49 am, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![THEBIGO](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea666f/32.png) [@THEBIGO](https://www.ruby-forum.com/u/THEBIGO)\
**Post date:** [July 15, 2008, 11:20pm UTC](https://www.ruby-forum.com/t/paginating-find-help-anyone/143095/4 "2008-07-15T23:20:21Z")

</div>

I think I may have figured it out  
In my index.rhtml for app/views/calls I tried this code

```
<% @recent_calls = @current_user.calls.find(:all, :page => {:size

```

=\> 4, :current =\> params[:page]}) %\>

```
    <ol>
        <% @recent_calls.each do |c| %>
            <li><%= link_to h(c.name), :action => 'show', :id =>

```

c.id %\>  
\<% end %\>  
  
\<%= paginating\_links(@recent\_calls) %\>

and it gave me only the 10 calls associated with the current\_user so I  
have to try a few more things  
and I want to have a previous link and a next link so I don’t have to  
click on the page numbers.

So thanks for the interest and help and thanks to alex wolf for the  
plug in for paginating\_links that works for me
