Ruby where子句返回nil对象?ActionView :: Template :: Error(nil:NilClass的未定义方法“ each”):

狗狗

我收到以下错误:

ActionView::Template::Error (undefined method `each' for nil:NilClass): 

这是where子句,第一个起作用。

def self.unpaid
  ARequest.where(:paid_on => nil).in(:status => [ARequest::TRANS_COMPLETE,ARequest::CANCELLED_BY]).gt(:total_owed_to_driver_in_cents => 0).asc(:assigned_driver_id).asc(:timestamp_requested)
end

这不起作用。

def self.allcall
  longtimeago = Time.now - 60.day
  yesterday = Time.now - 1.day
  ARequest.where(["paid_on >= ? AND paid_on <= ?", longtimeago.beginning_of_day, yesterday.end_of_day]).in(:status => [ARequest::TRANS_COMPLETE,ARequest::CANCELLED_BY]).gt(:total_owed => 0).asc(:assigned_driver_id).asc(:timestamp_requested)
end

上面抛出这个错误:

ActionView::Template::Error (undefined method `each' for nil:NilClass):

控制器代码

def allcalls
  ensure_root
  @calls = ARequest.allcall
end

路线

get "sme/allcalls"

只是尝试改变

where(["paid_on >= ? AND paid_on <= ?", longtimeago.beginning_of_day, yesterday.end_of_day]) 

where("paid_on >= ? AND paid_on <= ?", longtimeago.beginning_of_day, yesterday.end_of_day)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

Related 相关文章

热门标签

归档