Kaminari gem根据排序方向

时间:2018-05-24 09:10:41

标签: ruby-on-rails pagination kaminari

我正在使用Kaminari对连接表进行排序:

Hippy.includes(:flowers) # => 535

使用此代码:

Hippy.includes(:flowers).page(1).per(50).count # => 50

当我按升序排序时,我在11页上每页得到1条记录,这是我不期望的:

Hippy.includes(:flowers).order("flowers.id asc").page(1).per(50).count # => 1
Hippy.includes(:flowers).order("flowers.id asc").page(1).per(50).total_pages # => 11

撤销订单,我得到:

Hippy.includes(:flowers).order("flowers.id desc").page(1).per(50).count # => 5
Hippy.includes(:flowers).order("hippies.id desc").page(1).per(50).total_pages # => 50

在连接表订购时,Kaminari不工作吗?或者我做错了什么?

0 个答案:

没有答案