参数数量错误(1 为 0)使用 Rails 范围查找当前月份的所有参数时出错

Wrong number of Arguments (0 for 1) Error using Rails Scope to find all in current month

我是范围的新手,在创建范围时发现我认为可以在这里工作的东西 Rails scope created within month。但是,我下面的代码给出了错误数量的参数(0 代表 1),我不确定为什么。感谢您就此事提供的任何帮助。
给出问题的范围如下。

scope :contract_out,  -> (date) { where("DATE_PART('month', contract_out_date) = ?", date.month) }

要获取当前月份内的所有记录,请使用以下范围:

scope :contract_out, where("contract_out_date >= ? AND contract_out_date < ?", Date.today.beginning_of_month, Date.today.end_of_month)

要为任何月份工作,不仅是当前,范围将被修改为接受 1 个属性:

scope :contract_out, ->(date) {where("contract_out_date >= ? AND contract_out_date < ?", date.beginning_of_month, date.end_of_month)}