为什么我得到MongoID :: Criteria的未定义方法页面

时间:2019-04-10 20:00:07

标签: ruby-on-rails ruby mongodb

接管该项目并更新到Rail 4.2.11。我什么都没改变。我们正在使用Kaminari。我猜Mongo现在带回来了以前没有的东西?还是Kaminari是问题所在?

我收到以下错误

NoMethodError (undefined method `page' for #<Mongoid::Criteria:0x0070f088>):

在此行代码上

@calls = MyRequest.desc(:timestamp_requested).page(params[:page])

完整代码:

def calls_admin
ensure_root
@sort = params[:s] || 'requested'
@direction = params[:d] || 'desc'
if @direction == 'desc'
  case @sort
  when 'status'
    @calls = MyRequest.desc(:status, :timestamp_requested).page(params[:page])
  when 'requested'
    @calls = MyRequest.desc(:timestamp_requested).page(params[:page])
  when 'yo'
    @calls = MyRequest.desc(:name, :timestamp_requested).page(params[:page])
  when 'length'
    @calls = MyRequest.desc(:calculated_mileage).page(params[:page])
  when 'time'
    @calls = MyRequest.desc(:time_in_seconds).page(params[:page])
  when 'billing'
    @calls = MyRequest.page(params[:page])
  end

结束

0 个答案:

没有答案