Reputation: 437
I'm trying to use will_paginate and have done everything listed in the github installation/use instructions, but I'm getting a NameError when I try to load the page:
uninitialized constant BooksController::Books
In my Gemfile I have:
gem 'will_paginate', '~> 3.1.0'
In my controller I have:
def index
#paginate books, have 10 per page
@books = Books.paginate :page => params[:page], :per_page => 10
end
And in my index.html.erb, I have added:
<%= will_paginate @books %>
Has anyone encountered this? I've run bundle install, and the gem appeared to be installed.
Upvotes: 0
Views: 59
Reputation: 146
Use like this @books = Book.paginate :page => params[:page], :per_page => 10
Model name should not be plurals
Upvotes: 1