Search code examples
ruby-on-railsrubykaminari

Kaminari - undefined local variable or method `page' for


I was using will_paginate for pagination on my site but as we're using Active Admin I decided to change it to kaminari to avoid any of the conflict issues between the two. I removed will_paginate from the gem file and added kaminari, restarted the rails server and ran bundle install but I'm getting errors which suggest it has not been installed properly:

undefined local variable or method `page' for <SearchController:0x007fd546587140>

Rails version: 5

Gemfile:

gem 'kaminari', '~> 0.16.3'
#gem 'will_paginate', '~>3.1.6'

Controller:

...

 @properties = @properties.page(page[:params]).per(9)

Not sure what the issue is?


Solution

  • There is no object page in your controller...

    @properties = @properties.page(page[:params]).per(9)
    

    I think what you wanted to do was...

    @properties = @properties.page(params[:page]).per(9)