0

我收到此错误的参数数量错误(0 表示 1+)。我的代码

  vs = where(created_at: start.beginning_of_day..Time.zone.now)
  vs = where(owner_id: id)
  if cat == "store"
    vs = where.not(store_id: 0) 
  end

问题是那里的 if 条件,它不喜欢我在执行 where 子句之前尝试添加该条件的方式。
有没有办法根据 cat 变量是否存储将 where 子句添加到 vs ?谢谢

4

1 回答 1

0

不,问题不在于您如何添加条件。它是条件本身,因为where需要一个参数。where.not根本不起作用。

尝试where('store_id <> 0')

于 2013-09-10T21:44:42.243 回答