2011-01-28 55 views

回答

1

在Rails 3中,例如下面的檢索範圍內創建的用戶,你需要:

today8am = Time.now.at_beginning_of_day + 8.hours 
@users = User.where("created_at BETWEEN ? AND ?", today8am - 1.day, today8am) 

如果可能有很多的記錄和查詢被稱爲非常頻繁,我建議add index日期欄。

+0

非常感謝! – Augusto 2011-01-28 10:05:03

相關問題