Search code examples
ruby-on-railskaminari

Kaminari & Rails pagination - undefined method `num_pages'


Here's my controller:

def show        
    @user = User.find(params[:id])
    @microposts = @user.microposts.page(params[:page])
end

This is working fine if I dont add following code to show.html.erb:

<%= paginate @microposts %>

Its giving following error:

undefined method `num_pages' for #<ActiveRecord::Relation:0x007fc2ca54b228>

How can I fix this? Using Rails 3.2.8 & Kaminari 0.13.0


Solution

  • I have got my answer. I had google it and found that kaminari has some issue with will_paginate so i had run following command to uninstall will_paginate

    gem uninstall will_paginate
    

    Also restart the rails server and now its working fine.

    Thanks everyone.