我试图定义两个变量如下:
> @orders = Customer.find_all_by_order_date(nil)
> @nonorders = Customer.find_all_by_order_date(!nil)
第一个工作正常,但第二个没有.如何找到其order_date字段不为零的客户?
@nonorders = @ customer.orders.find(:all,:conditions =>“@ customer.orders.order_date IS NOT NULL”)
给我以下错误:
未定义的方法`extract_options_from_args!对于ActiveRecord :: Base:Class
我已经尝试更改条件,例如@ orders.order_date,@ customer.order.order_date等.导致此错误的原因是什么?谢谢!
解决方法
Rails3中:
@nonorders = Customers.where("customers.date IS NOT NULL")
Rails2:
@nonorders = Customers.find(:all,:conditions => "customers.date IS NOT NULL")