# RE: Pagination problem

**URL:** <https://www.ruby-forum.com/t/re-pagination-problem/95163>\
**Category:** Rails\
**Created:** [May 23, 2006, 4:06pm UTC](https://www.ruby-forum.com/t/re-pagination-problem/95163 "2006-05-23T16:06:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bharat\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c68b51/32.png) [@Bharat\_A](https://www.ruby-forum.com/u/Bharat_A)\
**Post date:** [May 23, 2006, 4:06pm UTC](https://www.ruby-forum.com/t/re-pagination-problem/95163/1 "2006-05-23T16:06:47Z")

</div>

> From: Arunkumar B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> In my table(public\_topics), i have 11 rows of data…  
> whenever i run the following view, it shows the entire rows in the  
> current page…

> It seems that pagination is not working…  
> whenever i click the pagination links,nothing change and the  
> same page  
> reload again with the same data…

> @public\_topics=PublicTopic.find\_by\_sql(“select \* from public\_topics  
> where category='” + params[:id] + “'” )

The problem is that you are overwriting the @public\_topics in your  
controller. The second statement negates the pagination call made  
earlier.  
To solve it, use the conditions option in the paginate method .  
@public\_topic\_pages, @public\_topics = paginate(:public\_topics,  
:per\_page=\>2, :conditions =\> ‘your condition here’)

The above line should work.

Hope that helps.  
Bharat

---

<div class="post-metadata">

**Author:** ![Bharat\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c68b51/32.png) [@Bharat\_A](https://www.ruby-forum.com/u/Bharat_A)\
**Post date:** [May 24, 2006, 6:37am UTC](https://www.ruby-forum.com/t/re-pagination-problem/95163/2 "2006-05-24T06:37:28Z")

</div>

Thanx , now it works well…

regards,  
Arun.
