1

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

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
Jitendra Gaur
  • 778
  • 4
  • 16
  • Is there any chance that you're using active admin? If yes, than this could apply to your problem: http://stackoverflow.com/questions/6919082/ruby-rails-kaminari-undefined-method-pagination-errors – Christoph Lupprich Aug 26 '12 at 17:02
  • no i am not using active admin simple pagination with kaminari. – Jitendra Gaur Aug 27 '12 at 03:20

1 Answers1

1

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.

Jitendra Gaur
  • 778
  • 4
  • 16
  • These two gems are generally incompatible, though there is a way to get them to coexist: See the last code block on this article: http://belighted.com/en/blog/will_paginate-vs-kaminari For the record, I think you should just choose one or the other, rather than monkey-patching them to coexist in this way. – aaaronic Mar 18 '16 at 19:48
  • I think your down vote of my answers was a bit harsh, considering you didn't mention you even had will_paginate installed – TomDunning Mar 31 '16 at 14:36