5
我正在计算完成的两个日期之间的所有记录。这意味着created_at字段介于start_date和end_date之间,finished_at字段不为空。用Rails中的多个条件计算
我可以使用下面的表达式来获得未完成的记录:
Record.count(:all, :conditions => {:created_at => start_date..end_date, :finished_at => nil })
有没有类似的方法来计算,其中在成品不为零的记录?
您可以使用一些宝石,如Squeel,meta-where。看到http://stackoverflow.com/questions/4252349/rail-3-where-condition-using-not-null – gayavat 2012-03-27 10:50:52
@gayavat我不认为Squeel支持功能之间,所以我必须做Record.count {(created_at > start_date)&(created_at
dcarneiro
2012-03-27 11:10:26