Pagination in forum does not work

Forums > Book - Chapter 5 > Pagination in forum does not work

Login to post a new topic

Author Message
novice
Member since 14 Nov 22:51
0 posts

Im getting this error:

NoMethodError in TopicsController#index undefined method 'paginate' for #<TopicsController:0x6f4f988> C:/Rails/rails_apps/railscoders/app/controllers/topics_controller.rb:4:in `index'


This is my index of topics_controller:


  def index
    @forum = Forum.find(params[:forum_id])
    @topics_pages, @topics = paginate(:topics,
    :include => :user,
    :conditions => ['forum_id - ?', @forum],
    :order => 'topics.updated_at DESC')

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @topics.to_xml }
    end
  end


my index in views/topics/index.rhtml

<% if @topics_pages.page_count > 1 %>
     Pages: 
    <%= pagination_links @topics_pages, :params => params  %> 
<% end %>


Why does not it work? Can anybody help me to solve pagination problem?
novice
Member since 14 Nov 22:51
0 posts

I have installed
- gem : 1.3.5
- rails: 2.3.4
- ruby: 1.8.6
- will_paginate 2.3.11

grapica
Member since 16 Aug 08:06
0 posts

I had the same problem, but I solved it.
Use classic_pagination plug-in instead of will_paginate
to install plug-in just type:
ruby script/plugin install http://github.com/masterkain/classic_pagination.git
I use:
gem -1.3.7
Rails -2.3.8
ruby -1.8.6