Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kaminari undefined method `page'

I've been trying to play around with the Kaminari gem for pagination, but am running into problems.

I've got a simple starter project with a simple model:

class Position < ActiveRecord::Base
  validates_presence_of :name
end

I'm running with ruby 1.9.2 and rails 3.0.5 on Ubuntu 10.04. I've installed kaminari (0.10.4).

From what I understand, I should be able to execute Position.order("name").page(1), but when I do so, I get the following:

ruby-1.9.2-p0 > Position.order("name").page(1)
NoMethodError: undefined method `page' for #<ActiveRecord::Relation:0xaacab34>
    from /home/bob/.rvm/gems/ruby-1.9.2-p0@talentskout/gems/activerecord-3.0.5/lib/active_record/relation.rb:371:in `method_missing'
    from (irb):2
    from /home/bob/.rvm/gems/ruby-1.9.2-p0@talentskout/gems/railties-3.0.5/lib/rails/commands/console.rb:44:in `start'
    from /home/bob/.rvm/gems/ruby-1.9.2-p0@talentskout/gems/railties-3.0.5/lib/rails/commands/console.rb:8:in `start'
    from /home/bob/.rvm/gems/ruby-1.9.2-p0@talentskout/gems/railties-3.0.5/lib/rails/commands.rb:23:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

This seems about as simple a scenario as I can get. Any ideas would be greatly appreciated.

Thanks.

like image 314
Spob Avatar asked Nov 29 '22 17:11

Spob


1 Answers

Rails noob here: had precisely the same issue but for a different reason - I found I had to restart the server after adding the kaminari gem and running bundle install. Just mentioning it in case someone else has the same problem!

like image 132
Polsonby Avatar answered Dec 02 '22 05:12

Polsonby