abhishek77in
abhishek77in

Reputation: 1896

Kaminari undefined method `page' with Rails 4.2

I am using Kaminari 0.16.3 with Rails 4.2.0. Not sure what is going wrong, I have pasted code run by me in console, which proves kaminari gem is loaded but page method is undefined on ActiveRecord model.

abhishek@abhishek ~/my_app (master●●)$ rails c                                                                     [ruby-2.1.5p273]
Loading development environment (Rails 4.2.0)
irb(main):001:0> Kaminari
=> Kaminari
irb(main):002:0> User.page
NoMethodError: undefined method `page' for User (call 'User.connection' to establish a connection):Class

Please note: I am intentionally calling page without any arguments to reproduce the issue.

Upvotes: 2

Views: 2808

Answers (2)

abhishek77in
abhishek77in

Reputation: 1896

Due to an issue with will_paginate and rails_admin I had this in my codebase causing the page method to be renamed to per_page_kaminari.

I have realized this late and fixed.

Kaminari.configure do |config|
  config.page_method_name = :per_page_kaminari
end

Upvotes: 7

Athar
Athar

Reputation: 3268

Have a look at this tutorial https://github.com/amatsuda/kaminari

This is how it works

 User.page(page_number).per(records_per_page)

Upvotes: 0

Related Questions