I'm trying to use the will_paginate gem but something's wrong. I'm stuck with an undefined method `paginate' error. I read many issues and try a lot of things.
Here's what I've got :
This is my LocationsController.rb:
def index
@locations = Location.all
respond_to do |format|
@locations = @locations.paginate(:page => params[:page], :per_page => 10)
format.html #index.html.erb
format.json { render json: @locations }
end
end
And this is my will_paginate's line in my index.html.erb:
<%= will_paginate @locations %>
And this is the error:
undefined method `paginate' for #<Class:0xaa2e48c>
I also add the require part in my Gemfile:
gem "will_paginate", "~> 3.0.4", :require => nil
And this at the end of my environment.rb:
require "will_paginate"`