Ruby on rails <;ActiveRecord::QueryMethods::正在工作的作用域上的WhereChain错误

Ruby on rails <;ActiveRecord::QueryMethods::正在工作的作用域上的WhereChain错误,ruby-on-rails,Ruby On Rails,我已经成功地运行了一段代码,但它刚刚开始抛出一个错误-我们改变了数据进入数据库的方式,但认为这更可能是编程问题,或者我错误地修改了它,但看不到在哪里 这个问题似乎是由范围引起的,我们运行的是Rails 4.2.2 完全错误是 undefined method `call' for ActiveRecord::QueryMethods::WhereChain:0x007feb8f5c49f0> Did you mean? caller app/controllers/orders_co

我已经成功地运行了一段代码,但它刚刚开始抛出一个错误-我们改变了数据进入数据库的方式,但认为这更可能是编程问题,或者我错误地修改了它,但看不到在哪里

这个问题似乎是由范围引起的,我们运行的是Rails 4.2.2

完全错误是

undefined method `call' for 
 ActiveRecord::QueryMethods::WhereChain:0x007feb8f5c49f0> Did you mean? caller

app/controllers/orders_controller.rb:158:in `weekly_sales_report'
在我的命令中,控制器第158行

@sales_this_week_bysales = Order.select("COUNT(order_id) AS nosales, AVG(net_amount) AS avgsale,SUM(sale_cost) AS sale_cost, SUM(net_amount) AS weeklysalestotal, owner_id AS salesman").sales.where.(date_of_sale: (@startdate .. @enddate)).with_salesman.group(:owner_id)
在我的orders.rb模型中,我使用了以下作用域

scope :with_salesman, -> { joins(:pipe_records).where(pipe_records: {pipe_part_id: 1}).where.not(pipe_records: {owner_id: nil}) }

scope :sales, -> {where ("orders.order_ref <>'' and date_of_sale IS NOT NULL ")}
scope:with_saller,->{joins(:pipe_records).where(pipe_records:{pipe_part_id:1}).where.not(pipe_records:{owner_id:nil})
范围:销售,->{其中(“orders.order\u ref”和销售日期不为空”)}
我将作用域重新写入下面,但仍然得到相同的错误

scope :with_salesman, -> { joins(" INNER JOIN pipe_records ON pipe_records.order_id = orders.id WHERE pipe_records.pipe_part_id =1 AND pipe_records.owner_id <>'' ") }
scope:with_saller,->{joins(“管道记录上的内部连接管道记录。订单号=orders.id,其中管道记录。管道零件号=1,管道记录。所有者号为“”)}
我还从sales.WHERE上删除了WHERE startdate标准,该标准返回了一个不同的错误,但范围似乎不再正确传递,或者由于不良记录而返回错误


我现在不确定发生了什么,我回到我的遥控器,从几天前的代码副本,这也引发了同样的错误,但它工作正常。最近,我们通过一种新的表格加入了许多新的记录,这种表格绕过并更改了在可能是原因的日期创建的记录。如果您有任何建议或新的见解,我将不胜感激。

您可能希望在
where
之后删除该句点:

where.(date_of_sale: (@startdate .. @enddate))

您可能希望删除
之后的句点,其中

where.(date_of_sale: (@startdate .. @enddate))

只需删除
where
和括号之间的句点

where.(date_of_sale: (@startdate..@enddate))
ruby

receiver.()

是receiver.call()的缩写,因此您收到的错误只需删除
where
和括号之间的句点即可

where.(date_of_sale: (@startdate..@enddate))
ruby

receiver.()

是receiver.call()的缩写,因此您收到的错误

是世界上最大的facepalm。。。。我看了一百遍都没看到,谢谢你,世界上最大的facepalm。。。。我看了一百遍都没看到,谢谢