0

I've found a lot of links regarding this problem googling. but nevertheless I still get this error after implementing those fixes. so my gemfile

gem 'will_paginate', '~> 2.3.16'

environment file

config.gem 'will_paginate', :version => '~> 2.3.16'

Controller

  def index
     @events = Event.paginate({:page => params[:page], :per_page => 10})
  end

View:

<% @events.each do |item| %>
...
<% end %>  
...  
<%= will_paginate @events %>  

I'm using rvm, console commands

rvm 1.8.7 do bundle install 
...
rvm use 1.8.7 do bundle exec rake gems:install

Could anyone help me with this problem?

Elmor
  • 4,775
  • 6
  • 38
  • 70

3 Answers3

0

try this one

      def index
         @events = Event.all.paginate({:page => params[:page], :per_page => 10})
      end

Note: If u get same error still, then just comment out logic of pagination and insert some records in your database table(model) and then use pagination.

Gopal S Rathore
  • 9,885
  • 3
  • 30
  • 38
  • paginate is method of a class, `all` return different instances. i think i'll go with endless page – Elmor Oct 20 '13 at 08:35
  • no, it will return all records from ur Event model only. And if u r not expecting it, then tell me what u r expecting from "Event.paginate" – Gopal S Rathore Oct 21 '13 at 05:04
0

You cannot call paginate on a model. It can be called on collections like hashes, array, ActiveRecord.

LHH
  • 3,233
  • 1
  • 20
  • 27
0

It may be just a case of restarting the server after you have installed the gem.

atw
  • 5,428
  • 10
  • 39
  • 63