0
查看此查詢有何錯誤?如何查詢最近幾周創建的記錄? ...現在至2周前
time_range = (Time.now..2.weeks.ago)
access_code = group.group_access_codes.where(:group_access_codes => {:uuid => code, :created_at => time_range}).first
它沒有返回有效記錄?下面是導致SQL:
SELECT "group_access_codes".*
FROM "group_access_codes"
WHERE "group_access_codes"."uuid" = 'ae342d4a13'
AND ("group_access_codes".group_id = 391)
AND ("group_access_codes"."created_at" BETWEEN '2012-01-05 00:53:34.811469' AND '2011-12-22 00:53:34.811521')
應該尋找記錄:
created_at = 2012-01-05 00:36:41.710613
感謝