Pagination problem

hi everybody,

i am new to rails…
plz clear my doubt…

this is my question

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…
and i have set the ‘:per_page’ option to ‘2’.so it must show two data
per page…but it shows all the rows in a single page…and this case
continue in all the pagination links…

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…

i hope this group will definetely help me to get rid of this simple
problem…

my view and the listing method is given below…


This is my controller/method

def listtopics

@public_topic_pages, @public_topics = paginate(:public_topics,
:per_page=>2)
@public_topics=PublicTopic.find_by_sql(“select * from public_topics
where category=’” + params[:id] + “’” )

end

This is my view

<%= error_messages_for ‘public_topic’ %>

Questions



<% for public_topic in @public_topics %>

<%=link_to "#{public_topic.topic}",:action=>"part" %>

<% end -%>
<%= if @public_topic_pages.current.previous link_to "< @public_topic_pages.current.previous } end %>          <%= if @public_topic_pages.current.next link_to "Next >>", { :page => @public_topic_pages.current.next } end %>

plz help me…

with regards,
Arun.

On Tuesday, May 23, 2006, at 3:20 PM, Arunkumar B. wrote:

and i have set the ‘:per_page’ option to ‘2’.so it must show two data
my view and the listing method is given below…

end %> -- Posted via http://www.ruby-forum.com/. _______________________________________________ Rails mailing list [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails

@public_topics=PublicTopic.find_by_sql(“select * from public_topics
where category='” + params[:id] + “'” )

This line is overwriting the paginated array of objects with all objects
that match the category. I suggest deleting this line and using

@public_topic_pages, @public_topics = paginate(:public_topics,
:per_page=>2, :conditions=>[“category = ?”,params[:id])

_Kevin