Search code examples
ruby-on-railsruby-on-rails-2will-paginate

rails 2.3 will_paginate 2.3.16 undefined method `paginate' for #<Class:0x7f0ed5f13138>


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?


Solution

  • 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.