2012年7月26日木曜日

how to fix undefined method `per' on Ruby on Rails 3

Environment

ruby-1.9.3-p0, rails3.2.2, postgres

Grade

easy


Active Admin uses kaminari for pagination. My app uses will_paginate for pagination. So I got error.

undefined method `per' for #<ActiveRecord::Relation:0x007feba7775fe8>

I fixed this.

Open Gemfile


vi Gemfile

gem 'kaminari'

bundle install

adding the kaminari gem to app Gemfile. Confirm install.


gem list

kaminari (0.13.0)
...
will_paginate (3.0.pre4)

There are both will_paginate gem and kaminari gem in app. but this does not work. Need to create config/initializers/kaminari.rb. adding description.

kaminari.rb


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

You reboot server and login. Your app will operate normally.
Thanks for reading. bye!


helping site

この記事がお役にたちましたらシェアをお願いします

このエントリーをはてなブックマークに追加

0 件のコメント:

コメントを投稿

Related Posts Plugin for WordPress, Blogger...