# Will\_paginate issue

**URL:** <https://www.ruby-forum.com/t/will-paginate-issue/154290>\
**Category:** Rails\
**Created:** [November 27, 2008, 12:30pm UTC](https://www.ruby-forum.com/t/will-paginate-issue/154290 "2008-11-27T12:30:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![petan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@petan](https://www.ruby-forum.com/u/petan)\
**Post date:** [November 27, 2008, 12:30pm UTC](https://www.ruby-forum.com/t/will-paginate-issue/154290/1 "2008-11-27T12:30:33Z")

</div>

Hi,

I am trying paginate (will\_paginate) users posts. It is counting and  
showing the page links correctly, but still showing all the posts on one  
page.

@entries = @user.entries.paginate :per\_page =\> 5, :page =\>  
params[:page], :order =\> ‘created\_at DESC’

If I change it to @entries = Entry.paginate :per\_page =\> 5 …  
It is fine, but I would like to show only given users posts.

Thx, pete

---

<div class="post-metadata">

**Author:** ![petan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@petan](https://www.ruby-forum.com/u/petan)\
**Post date:** [November 27, 2008, 12:40pm UTC](https://www.ruby-forum.com/t/will-paginate-issue/154290/2 "2008-11-27T12:40:19Z")

</div>

On Nov 27, 11:30 am, Petan C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> It is fine, but I would like to show only given users posts.

Is your entries association funny in any way ?

Fred

---

<div class="post-metadata">

**Author:** ![petan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@petan](https://www.ruby-forum.com/u/petan)\
**Post date:** [November 28, 2008, 9:23am UTC](https://www.ruby-forum.com/t/will-paginate-issue/154290/3 "2008-11-28T09:23:26Z")

</div>

Frederick C. wrote:

> Is your entries association funny in any way ?  
> Fred

Hi Fred,  
thanks. I have users and entries controller. In my show controller  
([mydomain.com/profile/:username](http://mydomain.com/profile/:username)), I am using \<% for entry in  
@user.entries %\> to show user posts. I dont know, if it is funny in any  
way or not. :).

USERSCONTROLLER:  
def show  
@entry = Entry.new  
username = params[:username]  
@user = User.find\_by\_username(username)  
@entries = @user.entries.paginate :per\_page =\> 3, :page =\>  
params[:page], :order =\> ‘created\_at DESC’  
.  
.  
.  
end

ENTRIESCONTROLLER:  
def show  
@entry = Entry.find\_by\_id\_and\_user\_id(params[:id], params[:user\_id],  
:include =\> [:user, [:comments =\> :user]])  
end

THX

---

<div class="post-metadata">

**Author:** ![petan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@petan](https://www.ruby-forum.com/u/petan)\
**Post date:** [November 28, 2008, 11:15am UTC](https://www.ruby-forum.com/t/will-paginate-issue/154290/4 "2008-11-28T11:15:47Z")

</div>

> That’s not what I meant. What I meant was does it have any interesting  
> options on it that might confuse will paginate ?
> 
> Fred

No, its just a plain text and thats it. It is a simple sideblog  
(user\_id,body,created\_at).Could it be problem, that I am using data from  
entries controller in User controller? Cheers, Pete

---

<div class="post-metadata">

**Author:** ![petan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@petan](https://www.ruby-forum.com/u/petan)\
**Post date:** [November 28, 2008, 10:36am UTC](https://www.ruby-forum.com/t/will-paginate-issue/154290/5 "2008-11-28T10:36:52Z")

</div>

On Nov 28, 8:23 am, Petan C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Frederick C. wrote:
> 
> > Is your entries association funny in any way ?  
> > Fred
> 
> Hi Fred,  
> thanks. I have users and entries controller. In my show controller  
> ([mydomain.com/profile/:username](http://mydomain.com/profile/:username)), I am using \<% for entry in  
> @user.entries %\> to show user posts. I dont know, if it is funny in any  
> way or not. :).

That’s not what I meant. What I meant was does it have any interesting  
options on it that might confuse will paginate ?

Fred

---

<div class="post-metadata">

**Author:** ![petan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@petan](https://www.ruby-forum.com/u/petan)\
**Post date:** [November 28, 2008, 2:04pm UTC](https://www.ruby-forum.com/t/will-paginate-issue/154290/6 "2008-11-28T14:04:14Z")

</div>

> If you actually have that line in your view you’ll be ignoring the  
> pagination stuff completely, since @entries is the thing with the  
> limited collection
> 
> Fred

Hi Fred,

all right, thanks. I’ve just tried to render the posts as collections of  
partials. \<%= render :partial =\> ‘user\_posts’, :collection =\>  
@user.entries %\>

But it is still the same. Is there another way to show only the users  
posts and then be able to paginate them? THX

---

<div class="post-metadata">

**Author:** ![petan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@petan](https://www.ruby-forum.com/u/petan)\
**Post date:** [November 28, 2008, 2:30pm UTC](https://www.ruby-forum.com/t/will-paginate-issue/154290/7 "2008-11-28T14:30:06Z")

</div>

On Nov 28, 1:04 pm, Petan C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> @user.entries %\>  
> no. you need :collection =\> @entries (assuming that in your controller  
> you’ve done @entries = @user.entries.paginate …

---

<div class="post-metadata">

**Author:** ![petan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@petan](https://www.ruby-forum.com/u/petan)\
**Post date:** [November 28, 2008, 11:25am UTC](https://www.ruby-forum.com/t/will-paginate-issue/154290/8 "2008-11-28T11:25:02Z")

</div>

On Nov 28, 10:15 am, Petan C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > That’s not what I meant. What I meant was does it have any interesting  
> > options on it that might confuse will paginate ?
> 
> > Fred
> 
> No, its just a plain text and thats it. It is a simple sideblog  
> (user\_id,body,created\_at).  
> That’s not what I meant. I was thinking of things like  
> custom :finder\_sql and so on

> Could it be problem, that I am using data from  
> entries controller in User controller?  
> No.

You mentionned

> I am using \<% for entry in  
> @user.entries %\> to show user posts. I dont know, if it is funny in any  
> way or not. :).

If you actually have that line in your view you’ll be ignoring the  
pagination stuff completely, since @entries is the thing with the  
limited collection

Fred
