0

When I use Kaminari gem with the code:

Model:

def index
 @posts = Post.page(params[:page])
end

And use it in index.html.erb:

It prints the next error:

undefined method `paginate' for #<#<Class:0x000000029bbd68>:0x000000029b3dc0>

red line on <%= paginate @posts %>.

How can I fix this problem? Is my @posts paginable? I think yes.

Sarkhan
  • 269
  • 1
  • 2
  • 9

1 Answers1

0

If it's in the Gemfile, then you just need to run bundle install instead of gem install Kaminari. I would then restart my rails server to ensure its initializers are run to properly require its files.

Tom Prats
  • 7,364
  • 9
  • 47
  • 77
  • Did you try it where Kaminari is lowercase? – Tom Prats Feb 04 '15 at 09:00
  • I can't really think of anything else, other gems could conflict, but it shouldn't give you that specific error. It looks like its just not being required, but rails should do that automatically if you have it setup correctly. Maybe you have a Kaminiri.config that is breaking something or something else is messing with the require – Tom Prats Feb 04 '15 at 09:22
  • I'm just saying I'm not sure what it is. Kaminari works in my project and all that was necessary was adding it to the Gemfile, bundle installing, and then restarting the server. Sorry i couldn't help. If your code is on Github, I could check it out more thoroughly – Tom Prats Feb 04 '15 at 09:24
  • That code is probably fine, it would likely be related to the initialization code. Also, are you two different users? – Tom Prats Feb 04 '15 at 09:33
  • Hey! It works in development mode now, but not in production mode. What is the problem? I restarted unicorn and nginx –  Feb 04 '15 at 10:43