From: Arunkumar B. [email protected]
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