Entries per page capped at 11 in console
mhartl opened this issue · 1 comments
mhartl commented
I’ve run into an odd issue when using will_paginate
in a Rails console. It appears that there is a hard cap of 11 entries per page, but only in the console (it works fine in an app). Using will_paginate
version 3.1.8
with a standard User model, I get the following results:
$ rails console
Loading development environment (Rails 6.0.0)
>> User.paginate(page: 1)
(1.1ms) SELECT sqlite_version(*)
User Load (0.2ms) SELECT "users".* FROM "users" LIMIT ? OFFSET ? [["LIMIT", 11], ["OFFSET", 0]]
=> #<ActiveRecord::Relation [#<User id: 1, …
>> User.paginate(page: 1, per_page: 5)
User Load (0.2ms) SELECT "users".* FROM "users" LIMIT ? OFFSET ? [["LIMIT", 5], ["OFFSET", 0]]
=> #<ActiveRecord::Relation [#<User id: 1, …
>> User.paginate(page: 1, per_page: 20)
User Load (0.2ms) SELECT "users".* FROM "users" LIMIT ? OFFSET ? [["LIMIT", 11], ["OFFSET", 0]]
=> #<ActiveRecord::Relation [#<User id: 1, …
Rather than the usual default of 30, the results are coming back 11 at a time. Moreover, an explicit per_page
parameter works fine for values less than 11, but appears to have no effect otherwise.
I’ve put a minimalist Rails app reproducing the issue up at GitHub here.
mhartl commented
It appears that the console limit of 11 comes from Active Record itself, so I’m closing this issue here. Thanks!