Will_paginate undefined method error - Ruby on Rails
I just installed the gem for will_paginate and it says it was installed successfully. I followed all the instructions listed in the plugin and I am getting undefined` paginate 'for' error method. Couldn't find a way to google search and couldn't fix it on my own (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 %>
UPDATE I used the console script / to determine if will_paginate was set correctly and it is not. I had to add:
config.gem 'will_paginate', :version => '~> 2.3.11', :source => 'http://gemcutter.org'
to the /config/environments.rb file and restart the server. Works great.
a source to share
I got an undefined method error with pearl will_paginate (using Rails 3) because I posted., By mistake.
gem 'will_paginate'
., in the wrong place in the Gemfile. Make sure to place it where it will be available to all runtimes - not nested inside a package for a cut environment such as:
group :test do
.
.
.
end
a source to share