will_paginate undefined method error - Ruby on Rails
Posted
by bgadoci
on Stack Overflow
See other posts from Stack Overflow
or by bgadoci
Published on 2010-04-15T04:46:53Z
Indexed on
2010/04/15
4:53 UTC
Read the original article
Hit count: 540
I just installed the gem for will_paginate and it says that it was installed successfully. I followed all the instructions listed with the plugin and I am getting an 'undefined method `paginate' for' error. Can't find much in the way of Google search and haven't been able to fix it myself (obviously). Here is the code:
PostsController
def index
@tag_counts = Tag.count(:group => :tag_name, :order => 'updated_at DESC', :limit => 10)
@posts = Post.paginate :page => params[:page], :per_page => 50
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @posts }
format.json { render :json => @posts }
format.atom
end
end
/model/post.rb
class Post < ActiveRecord::Base
validates_presence_of :body, :title
has_many :comments, :dependent => :destroy
has_many :tags, :dependent => :destroy
cattr_reader :per_page
@@per_page = 10
end
/posts/views/index.html.erb
<%= will_paginate @posts %>
© Stack Overflow or respective owner