我有一个方法如下...
def self.get(code)
where(code: normalize_code(code)).
where('coupon_count > 0').
where('expires_at > Time.now OR expires_at IS NULL').
take
end
我在“take”行上不断收到错误“参数数量错误(0 代表 1)”。我正在使用 rails 4.0.1 是导致问题还是我遗漏了什么?
我将方法更新为
def self.get(code)
where(code: normalize_code(code)).
where('coupon_count > 0').
where('expires_at > Time.now OR expires_at IS NULL').
take(1)
end
现在我得到了错误
SyntaxError: Unexpected identifier (16722)
错误在“take”行
-更新-
我的错误出现在优惠券计数的 where 方法中。它不在 take 方法中。在接受优惠券之前,我必须弄清楚它不会检查 coupon_count 字段的内容。