Forum: Ruby on Rails RE: Pagination problem

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
9163be77c2abb8146d6e7ad48af58553?d=identicon&s=25 Bharat Ahluwalia (Guest)
on 2006-05-23 16:06
(Received via mailing list)
> From: Arunkumar Balu <>

> 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
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.
C45e8b0eac09ee52dd88142e99b1094b?d=identicon&s=25 Arunkumar Balu (arun)
on 2006-05-24 06:37
(Received via mailing list)
Thanx , now it works well...

This topic is locked and can not be replied to.